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 <gitster@pobox.com>
Junio C Hamano committed
Oct 27, 2011 at 11:42 UTC
ea4f9685cb432caf357ad8af56a91877b6d04663
1 file changed
+2
-1
sha1_file.c
+2
-1
@@ -1267,7 +1267,8 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,
1267
while (c & 0x80) {
1268
if (len <= used || bitsizeof(long) <= shift) {
1269
error("bad object header");
1270
- return 0;
1270
+ size = used = 0;
1271
+ break;
1272
}
1273
c = buf[used++];
1274
size += (c & 0x7f) << shift;