[PATCH v2] locale: memory leak in newlocale (BZ #25770)

Dmitry Kovalenko d.kovalenko@postgrespro.ru
Wed May 21 11:11:12 GMT 2025


Hello Florian!

> I didn't write any code. 8-)

For me "Idea == Code"

>> +  (*tmp_buffer) = NULL;
>> +
>>   
>> I think this is redundant?

This is a “professional reflex” – pain from a difficult childhood.

I will remove it.

Questions:

1) Can I declare __newlocale_1 as static, too?

2) Can I use asserts in my __newlocale_1?

I want to check "tmp_buffer" in a debug code:

assert(tmp_buffer != NULL);

assert((*tmp_buffer) == NULL);

>> +
>> +      (*tmp_buffer) = locale_path;
>>       }
>>   
>>     /* Get the names for the locales we are interested in.  We either
> If __argz_add_sep fails, this still doesn't free locale_path.  You have
> to assign *tmp_buffer twice, or replace locale_path with tmp_buffer
> everywhere (and then call it locale_path or locale_path_ptr instead).

You are right. We should not to rely on the implementation of 
__argz_add_sep )

I will prepare the new patch v3 ASAP.

Thanks&Regards,

Dmitry Kovalenko



More information about the Libc-alpha mailing list