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.

>>>       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?


Reply via email to