From: Junio C Hamano Date: Thu, 27 Oct 2011 18:42:57 +0000 (-0700) Subject: unpack_object_header_buffer(): clear the size field upon error X-Git-Tag: v1.7.8.1~14^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ea4f9685cb432caf357ad8af56a91877b6d04663;p=git.git unpack_object_header_buffer(): clear the size field upon error The callers do not use the returned size when the function says it did not use any bytes and sets the type to OBJ_BAD, so this should not matter in practice, but it is a good code hygiene anyway. Signed-off-by: Junio C Hamano --- diff --git a/sha1_file.c b/sha1_file.c index 27f3b9b27..833f5b9b5 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1267,7 +1267,8 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf, while (c & 0x80) { if (len <= used || bitsizeof(long) <= shift) { error("bad object header"); - return 0; + size = used = 0; + break; } c = buf[used++]; size += (c & 0x7f) << shift;