Author: markj
Date: Fri Mar 20 20:02:53 2020
New Revision: 359183
URL: https://svnweb.freebsd.org/changeset/base/359183

Log:
  Fix uselocale(3) to not leak a reference to the old locale.
  
  In a single-threaded program pthread_getspecific() always returns NULL,
  so the old locale would not end up being freed.
  
  PR:           239520
  MFC after:    2 weeks
  Sponsored by: The FreeBSD Foundation

Modified:
  head/lib/libc/locale/xlocale.c

Modified: head/lib/libc/locale/xlocale.c
==============================================================================
--- head/lib/libc/locale/xlocale.c      Fri Mar 20 19:38:14 2020        
(r359182)
+++ head/lib/libc/locale/xlocale.c      Fri Mar 20 20:02:53 2020        
(r359183)
@@ -163,7 +163,7 @@ set_thread_locale(locale_t loc)
        if (NULL != l) {
                xlocale_retain((struct xlocale_refcounted*)l);
        }
-       locale_t old = pthread_getspecific(locale_info_key);
+       locale_t old = get_thread_locale();
        if ((NULL != old) && (l != old)) {
                xlocale_release((struct xlocale_refcounted*)old);
        }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to