Mac installer: eliminate minor memory leaks.

This commit is contained in:
Charlie Fenton 2013-06-18 05:45:16 -07:00
parent 53d28e5faa
commit 71a2a4350d
1 changed files with 16 additions and 0 deletions

View File

@ -295,6 +295,7 @@ void GetPreferredLanguages() {
aLanguage = CFStringCreateWithCString(NULL, "en", kCFStringEncodingMacRoman); aLanguage = CFStringCreateWithCString(NULL, "en", kCFStringEncodingMacRoman);
CFArrayAppendValue(supportedLanguages, aLanguage); CFArrayAppendValue(supportedLanguages, aLanguage);
CFRelease(aLanguage);
aLanguage = NULL; aLanguage = NULL;
dirp = opendir(Catalogs_Dir); dirp = opendir(Catalogs_Dir);
@ -315,6 +316,7 @@ void GetPreferredLanguages() {
// printf("Adding %s to supportedLanguages array\n", dp->d_name); // printf("Adding %s to supportedLanguages array\n", dp->d_name);
aLanguage = CFStringCreateWithCString(NULL, dp->d_name, kCFStringEncodingMacRoman); aLanguage = CFStringCreateWithCString(NULL, dp->d_name, kCFStringEncodingMacRoman);
CFArrayAppendValue(supportedLanguages, aLanguage); CFArrayAppendValue(supportedLanguages, aLanguage);
CFRelease(aLanguage);
aLanguage = NULL; aLanguage = NULL;
} }
@ -356,11 +358,25 @@ void GetPreferredLanguages() {
// further translation is needed for language en. // further translation is needed for language en.
if (!strcmp(language, "en")) { if (!strcmp(language, "en")) {
fclose(f); fclose(f);
CFRelease(preferredLanguages);
preferredLanguages = NULL;
CFArrayRemoveAllValues(supportedLanguages);
CFRelease(supportedLanguages);
supportedLanguages = NULL;
return; return;
} }
} }
CFRelease(preferredLanguages);
preferredLanguages = NULL;
} }
fclose(f); fclose(f);
CFArrayRemoveAllValues(supportedLanguages);
CFRelease(supportedLanguages);
supportedLanguages = NULL;
} }