Re: [PATCH v3 13/22] resolve_ref(): turn buffer into a proper string as soon as possible
- From
Thomas Rast <trast@student.ethz.ch>
- Date
- Sep 23, 2011, 08:17 UTC
- Message-ID
- <201109231017.55996.trast@student.ethz.ch>
- In-Reply-To
- <1316121043-29367-14-git-send-email-mhagger@alum.mit.edu>
Hi Michael
Michael Haggerty wrote:
Show 7 quoted lines
> Immediately strip off trailing spaces and null-terminate the string > holding the contents of the reference file; this allows the use of > string functions and avoids the need to keep separate track of the > string's length. (get_sha1_hex() fails automatically if the string is > too short.) > > Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
I'm getting valgrind failures in t1450-fsck and t3800-mktag which blame to this commit. For t1450 it looks as follows:
ok 5 - object with bad sha1
expecting success:
git rev-parse HEAD^{tree} >.git/refs/heads/invalid &&
test_when_finished "git update-ref -d refs/heads/invalid" &&
git fsck 2>out &&
cat out &&
grep "not a commit" out ==19623== Use of uninitialised value of size 8
==19623== at 0x4B6747: hexval (cache.h:798)
==19623== by 0x4B6797: get_sha1_hex (hex.c:42)
==19623== by 0x4DD12A: resolve_ref (refs.c:588)
==19623== by 0x4DC777: get_ref_dir (refs.c:313)
==19623== by 0x4DC6FA: get_ref_dir (refs.c:302)
==19623== by 0x4DC963: get_loose_refs (refs.c:368)
==19623== by 0x4DD556: do_for_each_ref (refs.c:687)
==19623== by 0x4DDA05: for_each_replace_ref (refs.c:806)
==19623== by 0x4E5CE9: prepare_replace_object (replace_object.c:86)
==19623== by 0x4E5D3C: do_lookup_replace_object (replace_object.c:103)
==19623== by 0x4C99BB: lookup_replace_object (cache.h:764)
==19623== by 0x4C9FA6: parse_object (object.c:191)
==19623== Uninitialised value was created by a stack allocation
==19623== at 0x4DCE34: resolve_ref (refs.c:498)or when I run it at the tip of pu instead of at the commit itself, line numbers are like so:
==2308== Use of uninitialised value of size 8
==2308== at 0x4ADB8B: get_sha1_hex (cache.h:800)
==2308== by 0x4D4283: resolve_ref (refs.c:629)
==2308== by 0x4D4851: get_ref_dir (refs.c:361)
==2308== by 0x4D48C6: get_ref_dir (refs.c:350)
==2308== by 0x4D4D29: do_for_each_ref (refs.c:412)
==2308== by 0x4DCD93: do_lookup_replace_object (replace_object.c:86)
==2308== by 0x4C31F4: parse_object (cache.h:764)
==2308== by 0x4F2A1D: get_sha1_1 (sha1_name.c:567)
==2308== by 0x4F2D5F: get_sha1_with_context_1 (sha1_name.c:1117)
==2308== by 0x4F3543: get_sha1 (cache.h:822)
==2308== by 0x461B50: cmd_rev_parse (rev-parse.c:723)
==2308== by 0x404B71: run_builtin (git.c:308)
==2308== Uninitialised value was created by a stack allocation
==2308== at 0x4D4006: resolve_ref (refs.c:530)Can you look into this?
--
Thomas Rast
trast@{inf,student}.ethz.ch