[PATCH 1/1] locale: Avoid use-after-invalidate

Florian Weimer fweimer@redhat.com
Fri Nov 6 22:50:53 GMT 2026


* Simon Richter:

> diff --git a/locale/programs/record-status.c b/locale/programs/record-status.c
> index f2d1131d31..dc40690ea8 100644
> --- a/locale/programs/record-status.c
> +++ b/locale/programs/record-status.c
> @@ -57,7 +57,9 @@ push_locale (void)
>    saved_errno = errno;
>  
>    orig = setlocale (LC_CTYPE, NULL);
> -  if (orig == NULL)
> +  if (orig != NULL)
> +    copy = strdup (orig);
> +  else
>      error (0, 0, "failed to read locale!");

While changing this, you could also switch to xstrdup for implicit error
checking.  Not that it matters in practice here, but we already use it
elsewhere in localedef.

Thanks,
Florian



More information about the Libc-alpha mailing list