2018-03-16 0:01 GMT+03:00 Eric Sunshine <sunshine@xxxxxxxxxxxxxx>: > On Thu, Mar 15, 2018 at 4:47 PM, Martin Ågren <martin.agren@xxxxxxxxx> wrote: >> These are "real" errors and yield several more changes in the remainder. >> Ignoring those BUG-type messages at the beginning of this patch would >> give a patch like the one below. >> >> +static int get_object(struct ref_array_item *ref, const struct object_id *oid, >> + int deref, struct object **obj, struct strbuf *err) >> { >> void *buf = get_obj(oid, obj, &size, &eaten); >> - if (!buf) >> - die(_("missing object %s for %s"), >> - oid_to_hex(oid), ref->refname); >> - if (!*obj) >> - die(_("parse_object_buffer failed on %s for %s"), >> - oid_to_hex(oid), ref->refname); >> - >> + if (!buf) { >> + strbuf_addf(err, _("missing object %s for %s"), oid_to_hex(oid), >> + ref->refname); >> + return -1; >> + } >> + if (!*obj) { >> + strbuf_addf(err, _("parse_object_buffer failed on %s for %s"), >> + oid_to_hex(oid), ref->refname); >> + return -1; > > Doesn't this leak 'buf'? Yes. Thanks a lot. > >> + } >> grab_values(ref->value, deref, *obj, buf, size); >> if (!eaten) >> free(buf); >> + return 0; >> }