Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Feb 2022 00:48:08 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: e1c53fc8e154 - stable/13 - xlocale.c: only call init_key() when locale was successfully allocated
Message-ID:  <202202090048.2190m81A083730@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=e1c53fc8e15491d03641736e07c743fcb4324b2f

commit e1c53fc8e15491d03641736e07c743fcb4324b2f
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-02-02 17:25:45 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-02-09 00:42:45 +0000

    xlocale.c: only call init_key() when locale was successfully allocated
    
    (cherry picked from commit 7bf532c9d447bfdf03f42a5c5092fb74740722b2)
---
 lib/libc/locale/xlocale.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/libc/locale/xlocale.c b/lib/libc/locale/xlocale.c
index 467d6e6e5aee..4bddc43c086b 100644
--- a/lib/libc/locale/xlocale.c
+++ b/lib/libc/locale/xlocale.c
@@ -257,13 +257,13 @@ newlocale(int mask, const char *locale, locale_t base)
 	int useenv = 0;
 	int success = 1;
 
-	_once(&once_control, init_key);
-
 	locale_t new = alloc_locale();
 	if (NULL == new) {
 		return (NULL);
 	}
 
+	_once(&once_control, init_key);
+
 	orig_base = base;
 	FIX_LOCALE(base);
 	copyflags(new, base);
@@ -312,12 +312,12 @@ duplocale(locale_t base)
 	locale_t new = alloc_locale();
 	int type;
 
-	_once(&once_control, init_key);
-
 	if (NULL == new) {
 		return (NULL);
 	}
 	
+	_once(&once_control, init_key);
+
 	FIX_LOCALE(base);
 	copyflags(new, base);
 



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