From 71a2a4350d28035ed6949c60f121c69b4f166c8b Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Tue, 18 Jun 2013 05:45:16 -0700 Subject: [PATCH] Mac installer: eliminate minor memory leaks. --- mac_installer/Installer.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mac_installer/Installer.cpp b/mac_installer/Installer.cpp index 076b8eb5f3..9c1a329ab5 100644 --- a/mac_installer/Installer.cpp +++ b/mac_installer/Installer.cpp @@ -295,6 +295,7 @@ void GetPreferredLanguages() { aLanguage = CFStringCreateWithCString(NULL, "en", kCFStringEncodingMacRoman); CFArrayAppendValue(supportedLanguages, aLanguage); + CFRelease(aLanguage); aLanguage = NULL; dirp = opendir(Catalogs_Dir); @@ -315,6 +316,7 @@ void GetPreferredLanguages() { // printf("Adding %s to supportedLanguages array\n", dp->d_name); aLanguage = CFStringCreateWithCString(NULL, dp->d_name, kCFStringEncodingMacRoman); CFArrayAppendValue(supportedLanguages, aLanguage); + CFRelease(aLanguage); aLanguage = NULL; } @@ -356,11 +358,25 @@ void GetPreferredLanguages() { // further translation is needed for language en. if (!strcmp(language, "en")) { fclose(f); + CFRelease(preferredLanguages); + preferredLanguages = NULL; + CFArrayRemoveAllValues(supportedLanguages); + CFRelease(supportedLanguages); + supportedLanguages = NULL; return; } } + + CFRelease(preferredLanguages); + preferredLanguages = NULL; + } + fclose(f); + + CFArrayRemoveAllValues(supportedLanguages); + CFRelease(supportedLanguages); + supportedLanguages = NULL; }