summaryrefslogtreecommitdiff
path: root/hw/xquartz/mach-startup
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2010-02-10 17:56:30 -0800
committerJeremy Huddleston <jeremyhu@apple.com>2010-02-15 15:03:49 -0800
commit4127e8e5be5c366eb752bbb8d7f0ff5b519e641b (patch)
treed16e5dc7dcaa683aceeca96888bfc1d3f55f812f /hw/xquartz/mach-startup
parentc686c5cbdc5f35744407af5f9aabbd18cc17714b (diff)
XQuartz: clang static analysis fixes
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Diffstat (limited to 'hw/xquartz/mach-startup')
-rw-r--r--hw/xquartz/mach-startup/bundle-main.c30
-rw-r--r--hw/xquartz/mach-startup/stub.c7
2 files changed, 23 insertions, 14 deletions
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 0366f3ba2..4872ff59b 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/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;
}
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index 89f9e1058..ccf5ab426 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -73,7 +73,6 @@ static void set_x11_path(void) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
CFURLRef appURL = NULL;
- CFBundleRef bundle = NULL;
OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), nil, nil, &appURL);
switch (osstatus) {
@@ -84,12 +83,6 @@ static void set_x11_path(void) {
exit(1);
}
- bundle = CFBundleCreate(NULL, appURL);
- if(!bundle) {
- fprintf(stderr, "Xquartz: Null value returned from CFBundleCreate().\n");
- exit(2);
- }
-
if (!CFURLGetFileSystemRepresentation(appURL, true, (unsigned char *)x11_path, sizeof(x11_path))) {
fprintf(stderr, "Xquartz: Error resolving URL for %s\n", kX11AppBundleId);
exit(3);