[PATCH v7] locale: memory leak in newlocale [BZ #25770]

Florian Weimer fweimer@redhat.com
Wed Jun 4 08:17:45 GMT 2025


* Dmitry Kovalenko:

> diff --git a/locale/Makefile b/locale/Makefile
> index 9d9c1a7691..a9d29d08bc 100644
> --- a/locale/Makefile
> +++ b/locale/Makefile
> @@ -47,6 +47,7 @@ tests = \

> +
> +ifeq ($(run-built-tests),yes)
> +endif # $(run-built-tests) == yes
> +

Please remove this superfluous conditional.


> diff --git a/locale/tst-newlocale.c b/locale/tst-newlocale.c
> new file mode 100755
> index 0000000000..bab1ff8ba5
> --- /dev/null
> +++ b/locale/tst-newlocale.c
> @@ -0,0 +1,54 @@
> +/* This test checks a memory leak in newlocal function [BZ #25770].
> +   Copyright The GNU Toolchain Authors.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */

The URL should use https://, not http://.  Not sure where you found that
old copy. 8-)

> +
> +#include <support/check.h>
> +#include <mcheck.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <locale.h>
> +
> +static int
> +do_test (void)
> +{
> +  mtrace ();
> +
> +  {
> +    /*  We can use an any valid path here. */

The comment should end like this: here.  */
(Two spaces at end of comment.)

> +    int const r = setenv ("LOCPATH", ".", 1);
> +
> +    if (r != 0)
> +      {
> +        FAIL_EXIT1 ("putenv: %m");
> +      }
> +  }

The braces are not required (also below).  The error message should say
"setenv".

And I think that's it.  Getting really close now. 8-)

Thanks,
Florian



More information about the Libc-alpha mailing list