Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-06-27 17:24:55 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-06-27 17:24:55 +0400
commitb466a5c9a9f1147da9f3c0e5970c740b62e142f5 (patch)
treefa8f3df0da2aaea3cbc2e8bb921dbf80b3fed70c /intern
parentee85587a4368d568f1310e3c6bc0a8e225c0c4dc (diff)
Fix #35890: memory leak in OS X ghost locale detection.
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm6
-rw-r--r--intern/locale/boost_locale_wrapper.cpp4
2 files changed, 6 insertions, 4 deletions
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 607b6ae77b2..01a760609ff 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -549,7 +549,7 @@ int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op)
#pragma mark initialization/finalization
-const char *user_locale; // Global current user locale
+char GHOST_user_locale[128]; // Global current user locale
GHOST_SystemCocoa::GHOST_SystemCocoa()
{
@@ -590,11 +590,13 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
m_ignoreWindowSizedMessages = false;
//Get current locale
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CFLocaleRef myCFLocale = CFLocaleCopyCurrent();
NSLocale * myNSLocale = (NSLocale *) myCFLocale;
[myNSLocale autorelease];
NSString *nsIdentifier = [myNSLocale localeIdentifier];
- user_locale = [nsIdentifier UTF8String];
+ strncpy(GHOST_user_locale, [nsIdentifier UTF8String], sizeof(GHOST_user_locale) - 1);
+ [pool drain];
}
GHOST_SystemCocoa::~GHOST_SystemCocoa()
diff --git a/intern/locale/boost_locale_wrapper.cpp b/intern/locale/boost_locale_wrapper.cpp
index 3492ec05e82..5d7ba599467 100644
--- a/intern/locale/boost_locale_wrapper.cpp
+++ b/intern/locale/boost_locale_wrapper.cpp
@@ -65,8 +65,8 @@ void bl_locale_set(const char *locale)
}
else {
#ifdef __APPLE__
- extern const char *user_locale; // pulled from Ghost_SystemCocoa
- std::string locale_osx = user_locale + std::string(".UTF-8");
+ extern char GHOST_user_locale[128]; // pulled from Ghost_SystemCocoa
+ std::string locale_osx = GHOST_user_locale + std::string(".UTF-8");
_locale = gen(locale_osx.c_str());
#else
_locale = gen("");