aboutsummaryrefslogtreecommitdiff
path: root/remote-testsvn.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-12-14 17:11:44 -0500
committerJunio C Hamano <gitster@pobox.com>2012-12-15 10:43:11 -0800
commitbfae342c973b0be3c9e99d3d86ed2e6b152b4a6b (patch)
treebcc25ccd70fdb73871642933f708beaf8e13edb6 /remote-testsvn.c
parent790c83cda92f95f1b4b91e2ddc056a52a99a055d (diff)
downloadgit-bfae342c973b0be3c9e99d3d86ed2e6b152b4a6b.tar.gz
git-bfae342c973b0be3c9e99d3d86ed2e6b152b4a6b.tar.xz
remote-testsvn: fix unitialized variable
In remote-test-svn, there is a parse_rev_note function to parse lines of the form "Revision-number" from notes. If it finds such a line and parses it, it returns 0, copying the value into a "struct rev_note". If it finds an entry that is garbled or out of range, it returns -1 to signal an error. However, if it does not find any "Revision-number" line at all, it returns success but does not put anything into the rev_note. So upon a successful return, the rev_note may or may not be initialized, and the caller has no way of knowing. gcc does not usually catch the use of the unitialized variable because the conditional assignment happens in a separate function from the point of use. However, when compiling with -O3, gcc will inline parse_rev_note and notice the problem. We can fix it by returning "-1" when no note is found (so on a zero return, we always found a valid value). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote-testsvn.c')
-rw-r--r--remote-testsvn.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/remote-testsvn.c b/remote-testsvn.c
index 51fba059a..5ddf11cc6 100644
--- a/remote-testsvn.c
+++ b/remote-testsvn.c
@@ -90,10 +90,12 @@ static int parse_rev_note(const char *msg, struct rev_note *res)
if (end == value || i < 0 || i > UINT32_MAX)
return -1;
res->rev_nr = i;
+ return 0;
}
msg += len + 1;
}
- return 0;
+ /* didn't find it */
+ return -1;
}
static int note2mark_cb(const unsigned char *object_sha1,