summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--attr.c2
-rwxr-xr-xt/t0003-attributes.sh6
2 files changed, 7 insertions, 1 deletions
diff --git a/attr.c b/attr.c
index 4a1244f9a9..b1d1d6d791 100644
--- a/attr.c
+++ b/attr.c
@@ -53,7 +53,7 @@ static int invalid_attr_name(const char *name, int namelen)
* Attribute name cannot begin with '-' and must consist of
* characters from [-A-Za-z0-9_.].
*/
- if (*name == '-')
+ if (namelen <= 0 || *name == '-')
return -1;
while (namelen--) {
char ch = *name++;
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index ebbc7554a7..8c76b79bb0 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -42,6 +42,12 @@ test_expect_success 'setup' '
'
+test_expect_success 'command line checks' '
+
+ test_must_fail git check-attr "" -- f
+
+'
+
test_expect_success 'attribute test' '
attr_check f f &&