чт, 2 янв. 2025 г. в 21:46, Miroslav Zagorac <z...@fly-etf.net>:
> On 02. 01. 2025. 21:40, Илья Шипицин wrote: > > Honestly, I think those elements must be deallocated on program exit, > > not only if something failed during allocation. > > > > but I did not check that > > > > That is correct. However, the calloc() result is not checked before > strdup() > either, so the patch is not good. > I did not pretend to add "calloc" check for this patch. we have dedicated *dev/coccinelle/unchecked-calloc.cocci *script which allows us to detect unchecked "calloc". no worry, it won't be forgotten > > >>> while (*(args[cur_arg])) { > >>> name = calloc(1, sizeof(*name)); > >>> name->name = strdup(args[cur_arg]); > >>> + if (name->name == NULL) { > >>> + memprintf(err,"Out of memory."); > >>> + goto fail_free_name; > >>> + } > >>> LIST_APPEND(&global_51degrees.property_names, > &name->list); > >>> ++cur_arg; > >>> } > >>> > >>> return 0; > >>> + > >>> +fail_free_name: > >>> + free(name); > >>> +fail: > >>> + return -1; > > -- > Miroslav Zagorac > > What can change the nature of a man? >