Skip to content

Commit fb630e0

Browse files
peffgitster
authored andcommitted
tag: die when listing missing or corrupt objects
We don't usually bother looking at tagged objects at all when listing. However, if "-n" is specified, we open the objects to read the annotations of the tags. If we fail to read an object, or if the object has zero length, we simply silently return. The first case is an indication of a broken or corrupt repo, and we should notify the user of the error. The second case is OK to silently ignore; however, the existing code leaked the buffer returned by read_sha1_file. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ca51699 commit fb630e0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

builtin/tag.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,12 @@ static void show_tag_lines(const unsigned char *sha1, int lines)
9393
size_t len;
9494

9595
buf = read_sha1_file(sha1, &type, &size);
96-
if (!buf || !size)
96+
if (!buf)
97+
die_errno("unable to read object %s", sha1_to_hex(sha1));
98+
if (!size) {
99+
free(buf);
97100
return;
101+
}
98102

99103
/* skip header */
100104
sp = strstr(buf, "\n\n");

0 commit comments

Comments
 (0)