Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Mar 2020 20:02:53 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r359183 - head/lib/libc/locale
Message-ID:  <202003202002.02KK2rT2009220@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202003202002.02KK2rT2009220>