Protect against GSPrivateNativeCStringEncoding() corrupting the return

value of setlocale(). Bug #52331 reported by Jakub Wilk <jwilk@jwilk.net>.
This commit is contained in:
fredkiefer 2017-11-04 23:53:12 +01:00
parent ded6cf852a
commit 7c68c30928
2 changed files with 11 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2017-11-04 Fred Kiefer <fredkiefer@gmx.de>
* Source/GSLocale.m: Protect against
GSPrivateNativeCStringEncoding() corrupting the return value of
setlocale(). Bug #52331 reported by Jakub Wilk <jwilk@jwilk.net>.
2017-10-26 Stefan Bidigaray <stefanbidi@gmail.com>
* Source/NSDateFormatter.m: Fix how UDateFormat is created. Fixes

View file

@ -64,6 +64,10 @@ static NSString *
privateSetLocale(int category, NSString *locale)
{
const char *clocale = NULL;
/* Need to get the encoding first as the function call invalidates
* the return value of setlocale()
*/
NSStringEncoding enc = GSPrivateNativeCStringEncoding();
if (locale != nil)
{
clocale = [locale cString];
@ -72,7 +76,7 @@ privateSetLocale(int category, NSString *locale)
if (clocale != NULL)
{
return ToString(clocale);
return [NSString stringWithCString: clocale encoding: enc];
}
return nil;
}