aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xquartz/mach-startup/bundle-main.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-02-24 18:34:17 +0000
committermarha <marha@users.sourceforge.net>2010-02-24 18:34:17 +0000
commit24bc15a386e37908396c3f6088f6fc98ceaa0f46 (patch)
treec66f27ec96c869f10ef53d73ed7dd5e5e0860605 /xorg-server/hw/xquartz/mach-startup/bundle-main.c
parent6f0a8e51f20073ea01ac5dae8e5c4d49076fc65e (diff)
downloadvcxsrv-24bc15a386e37908396c3f6088f6fc98ceaa0f46.tar.gz
vcxsrv-24bc15a386e37908396c3f6088f6fc98ceaa0f46.tar.bz2
vcxsrv-24bc15a386e37908396c3f6088f6fc98ceaa0f46.zip
Git update 24/2/2010"
Diffstat (limited to 'xorg-server/hw/xquartz/mach-startup/bundle-main.c')
-rw-r--r--xorg-server/hw/xquartz/mach-startup/bundle-main.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/xorg-server/hw/xquartz/mach-startup/bundle-main.c b/xorg-server/hw/xquartz/mach-startup/bundle-main.c
index 0366f3ba2..4872ff59b 100644
--- a/xorg-server/hw/xquartz/mach-startup/bundle-main.c
+++ b/xorg-server/hw/xquartz/mach-startup/bundle-main.c
@@ -641,30 +641,46 @@ static int execute(const char *command) {
static char *command_from_prefs(const char *key, const char *default_value) {
char *command = NULL;
- CFStringRef cfKey = CFStringCreateWithCString(NULL, key, kCFStringEncodingASCII);
- CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(cfKey, kCFPreferencesCurrentApplication);
+ CFStringRef cfKey;
+ CFPropertyListRef PlistRef;
+
+ if(!key)
+ return NULL;
+
+ cfKey = CFStringCreateWithCString(NULL, key, kCFStringEncodingASCII);
+
+ if(!cfKey)
+ return NULL;
+
+ PlistRef = CFPreferencesCopyAppValue(cfKey, kCFPreferencesCurrentApplication);
if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
CFStringRef cfDefaultValue = CFStringCreateWithCString(NULL, default_value, kCFStringEncodingASCII);
int len = strlen(default_value) + 1;
+ if(!cfDefaultValue)
+ goto command_from_prefs_out;
+
CFPreferencesSetAppValue(cfKey, cfDefaultValue, kCFPreferencesCurrentApplication);
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
+ CFRelease(cfDefaultValue);
command = (char *)malloc(len * sizeof(char));
if(!command)
- return NULL;
+ goto command_from_prefs_out;
strcpy(command, default_value);
} else {
int len = CFStringGetLength((CFStringRef)PlistRef) + 1;
command = (char *)malloc(len * sizeof(char));
if(!command)
- return NULL;
+ goto command_from_prefs_out;
CFStringGetCString((CFStringRef)PlistRef, command, len, kCFStringEncodingASCII);
- }
-
+ }
+
+command_from_prefs_out:
if (PlistRef)
CFRelease(PlistRef);
-
+ if(cfKey)
+ CFRelease(cfKey);
return command;
}