summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2013-01-31 20:23:30 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2013-01-31 20:23:30 +0100
commite5ef0f18141409fc932d2c9cc0a42b769a880927 (patch)
treeeef7f0e6b005913543a88be1c6db60a449197069 /src
parent5f9f69d983d7ebc2d9d29cf295e86f32ab12906d (diff)
downloadlibgit2-e5ef0f18141409fc932d2c9cc0a42b769a880927.tar.gz
refs: handle ALLOW_ONELEVEL normalization with leading slash
A leading slash confuses the name normalization code when the flags include ALLOW_ONELEVEL. Catch this case in particular to avoid triggering an assertion in the uppercase check which expects us not to pass it an empty string. The existing tests don't catch this as they simply use the NORMAL flag. This fixes #1300.
Diffstat (limited to 'src')
-rw-r--r--src/refs.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/refs.c b/src/refs.c
index 52e0adac6..e75f51001 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -1691,6 +1691,11 @@ int git_reference__normalize_name(
segments_count++;
}
+ /* This means that there's a leading slash in the refname */
+ if (segment_len == 0 && segments_count == 0) {
+ goto cleanup;
+ }
+
if (current[segment_len] == '\0')
break;