Explorar o código

fix uselocale((locale_t)0) not to modify locale

commit 68630b55c0c7219fe9df70dc28ffbf9efc8021d8 made the new locale to
be assigned unconditonally resulting in crashes later on.
Timo Teräs %!s(int64=10) %!d(string=hai) anos
pai
achega
63f4b9f18f
Modificáronse 1 ficheiros con 1 adicións e 3 borrados
  1. 1 3
      src/locale/uselocale.c

+ 1 - 3
src/locale/uselocale.c

@@ -8,9 +8,7 @@ locale_t __uselocale(locale_t new)
 	locale_t old = self->locale;
 	locale_t global = &libc.global_locale;
 
-	if (new == LC_GLOBAL_LOCALE) new = global;
-
-	self->locale = new;
+	if (new) self->locale = new == LC_GLOBAL_LOCALE ? global : new;
 
 	return old == global ? LC_GLOBAL_LOCALE : old;
 }