From b5d8b253b194f3261bf790362d80eacb97ff30b5 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 28 Sep 2009 16:32:32 +0200 Subject: getMacPreferredLanguageAndCountry: Fix possible crash getMacPreferredLanguageAndCountry can crash when called e.g. as a root user because CFPreferencesCopyValue will return 0. Reviewed-by: denis Task-number: 261664 --- src/corelib/tools/qlocale.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 136bafa..dc61adb 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -1156,7 +1156,7 @@ static void getMacPreferredLanguageAndCountry(QString *language, QString *countr kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - if (CFArrayGetCount(languages) > 0) { + if (languages && CFArrayGetCount(languages) > 0) { QCFType locale = CFLocaleCreate(kCFAllocatorDefault, CFStringRef(CFArrayGetValueAtIndex(languages, 0))); if (language) -- cgit v0.12