]> git.ipfire.org Git - thirdparty/git.git/blobdiff - tag.c
Merge branch 'rs/pull-leakfix'
[thirdparty/git.git] / tag.c
diff --git a/tag.c b/tag.c
index bfa0e3143580f4f817fa0722a77224e81c58b615..71b544467efacd12f36e8c61efdc387db11d1bff 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -141,7 +141,16 @@ int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, u
 
        if (item->object.parsed)
                return 0;
-       item->object.parsed = 1;
+
+       if (item->tag) {
+               /*
+                * Presumably left over from a previous failed parse;
+                * clear it out in preparation for re-parsing (we'll probably
+                * hit the same error, which lets us tell our current caller
+                * about the problem).
+                */
+               FREE_AND_NULL(item->tag);
+       }
 
        if (size < the_hash_algo->hexsz + 24)
                return -1;
@@ -167,10 +176,15 @@ int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, u
        } else if (!strcmp(type, tag_type)) {
                item->tagged = (struct object *)lookup_tag(r, &oid);
        } else {
-               error("Unknown type %s", type);
-               item->tagged = NULL;
+               return error("unknown tag type '%s' in %s",
+                            type, oid_to_hex(&item->object.oid));
        }
 
+       if (!item->tagged)
+               return error("bad tag pointer to %s in %s",
+                            oid_to_hex(&oid),
+                            oid_to_hex(&item->object.oid));
+
        if (bufptr + 4 < tail && starts_with(bufptr, "tag "))
                ;               /* good */
        else
@@ -187,6 +201,7 @@ int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, u
        else
                item->date = 0;
 
+       item->object.parsed = 1;
        return 0;
 }