Skip to content

Commit

Permalink
unpack_object_header_buffer(): clear the size field upon error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
gitster committed Oct 27, 2011
1 parent 9c6bebd commit ea4f968
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sha1_file.c
Expand Up @@ -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;
Expand Down

0 comments on commit ea4f968

Please sign in to comment.