git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 5/5] ref-filter: get_ref_atom_value() error handling

From
Оля Тележная <olyatelezhnaya@gmail.com>
Date
Mar 16, 2018, 07:20 UTC
Message-ID
<CAL21BmmXz7wsq9kPzbvjo3b5ZEvmZA5qi-XqoXf6X8rRwOg_aQ@mail.gmail.com>
In-Reply-To
<CAPig+cRbsDTTfbeQS5tXCCoDKvf2pXAe_suGs-yHY_qj=Go_1A@mail.gmail.com>
2018-03-16 0:01 GMT+03:00 Eric Sunshine <sunshine@sunshineco.com>:
Show 27 quoted lines
> On Thu, Mar 15, 2018 at 4:47 PM, Martin Ågren <martin.agren@gmail.com> 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.
Show 7 quoted lines
>
>> +       }
>>         grab_values(ref->value, deref, *obj, buf, size);
>>         if (!eaten)
>>                 free(buf);
>> +       return 0;
>>  }
Previous: Eric SunshineNext: Junio C Hamano
Message 5 of 30 in “ref-filter: start adding strbufs with errors”
  1. 1/5 ref-filter: start adding strbufs with errorsOlga Telezhnaya, Mar 14, 2018
  2. 5/5 ref-filter: get_ref_atom_value() error handlingOlga Telezhnaya, Mar 14, 2018
  3. Martin ÅgrenMar 15, 2018
  4. Eric SunshineMar 15, 2018
  5. Оля ТележнаяMar 16, 2018
  6. Junio C HamanoMar 15, 2018
  7. Оля ТележнаяMar 16, 2018
  8. 3/5 ref-filter: change parsing function error handlingOlga Telezhnaya, Mar 14, 2018
  9. Junio C HamanoMar 15, 2018
  10. Оля ТележнаяMar 16, 2018
  11. 4/5 ref-filter: add return value to parsersOlga Telezhnaya, Mar 14, 2018
  12. 2/5 ref-filter: add return value && strbuf to handlersOlga Telezhnaya, Mar 14, 2018
  13. 1/5 ref-filter: start adding strbufs with errorsOlga Telezhnaya, Mar 19, 2018
  14. 3/5 ref-filter: change parsing function error handlingOlga Telezhnaya, Mar 19, 2018
  15. Junio C HamanoMar 19, 2018
  16. 5/5 ref-filter: get_ref_atom_value() error handlingOlga Telezhnaya, Mar 19, 2018
  17. 2/5 ref-filter: add return value && strbuf to handlersOlga Telezhnaya, Mar 19, 2018
  18. Junio C HamanoMar 19, 2018
  19. 4/5 ref-filter: add return value to parsersOlga Telezhnaya, Mar 19, 2018
  20. 1/5 ref-filter: start adding strbufs with errorsOlga Telezhnaya, Mar 20, 2018
  21. 5/5 ref-filter: get_ref_atom_value() error handlingOlga Telezhnaya, Mar 20, 2018
  22. Eric SunshineMar 20, 2018
  23. Junio C HamanoMar 20, 2018
  24. Eric SunshineMar 20, 2018
  25. Junio C HamanoMar 21, 2018
  26. Eric SunshineMar 21, 2018
  27. 3/5 ref-filter: change parsing function error handlingOlga Telezhnaya, Mar 20, 2018
  28. 2/5 ref-filter: add return value && strbuf to handlersOlga Telezhnaya, Mar 20, 2018
  29. Eric SunshineMar 20, 2018
  30. 4/5 ref-filter: add return value to parsersOlga Telezhnaya, Mar 20, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.