[PATCH v2] locale: memory leak in newlocale (BZ #25770)
Florian Weimer
fweimer@redhat.com
Tue May 20 18:34:51 GMT 2025
* Dmitry Kovalenko:
> Co-authored-by: Florian Weimer <fweimer@redhat.com>
I didn't write any code. 8-)
> @@ -51,6 +51,8 @@ __newlocale (int category_mask, const char *locale, locale_t base)
> int cnt;
> size_t names_len;
>
> + (*tmp_buffer) = NULL;
> +
> /* We treat LC_ALL in the same way as if all bits were set. */
> if (category_mask == 1 << LC_ALL)
> category_mask = (1 << __LC_LAST) - 1 - (1 << LC_ALL);
I think this is redundant?
> @@ -111,6 +113,8 @@ __newlocale (int category_mask, const char *locale, locale_t base)
> if (__argz_add_sep (&locale_path, &locale_path_len,
> _nl_default_locale_path, ':') != 0)
> return 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).
Thanks,
Florian
More information about the Libc-alpha
mailing list