[PATCH v8] locale: memory leak in newlocale [BZ #25770]
Florian Weimer
fweimer@redhat.com
Wed Jun 4 19:11:18 GMT 2025
* Dmitry Kovalenko:
> You could use TEST_COMPARE and TEST_VERIFY instead, then you won't even
> have to write a message. 8-)
>
> Sorry for an unformatted code and a mistake in usage of errno in my previous email (
>
> ---------
>
> { /* We can use an any valid path here. */ int const r = setenv ("LOCPATH", ".", 1); if (r != 0) FAIL_EXIT1
> ("setenv failed: (errno %d) %m", errno); } { locale_t const l = newlocale (1 << LC_CTYPE, "POSIX", NULL);
> if (l == NULL) FAIL_EXIT1 ("newlocale failed: (errno %d) %m", errno); freelocale (l); }
>
> ---------
It's still garbled on my end. The error checking is not the core
purpose of the test, so you can write this
TEST_COMPARE (setenv ("LOCPATH", ".", 1), 0);
and
locale_t const l = newlocale (1 << LC_CTYPE, "POSIX", NULL);
TEST_VERIFY_EXIT (l != NULL);
instead.
Thanks,
Florian
More information about the Libc-alpha
mailing list