diff --git a/src/sdl/macosx/mac_alert.c b/src/sdl/macosx/mac_alert.c
index 455e36509547e40af0a4a65f13f0e5517fb5dc24..2a139041a65157d8852951156413a29eaaa3c943 100644
--- a/src/sdl/macosx/mac_alert.c
+++ b/src/sdl/macosx/mac_alert.c
@@ -25,19 +25,38 @@
 #include "mac_alert.h"
 #include <CoreFoundation/CoreFoundation.h>
 
+#define CFSTRINGIFY(x) CFStringCreateWithCString(NULL, x, kCFStringEncodingASCII)
+
 int MacShowAlert(const char *title, const char *message, const char *button1, const char *button2, const char *button3)
 {
 	CFOptionFlags results;
 
-	CFUserNotificationDisplayAlert(0,
-	 kCFUserNotificationStopAlertLevel | kCFUserNotificationNoDefaultButtonFlag,
-	 NULL, NULL, NULL,
-	 CFStringCreateWithCString(NULL, title, kCFStringEncodingASCII),
-	 CFStringCreateWithCString(NULL, message, kCFStringEncodingASCII),
-	 button1 != NULL ? CFStringCreateWithCString(NULL, button1, kCFStringEncodingASCII) : NULL,
-	 button2 != NULL ? CFStringCreateWithCString(NULL, button2, kCFStringEncodingASCII) : NULL,
-	 button3 != NULL ? CFStringCreateWithCString(NULL, button3, kCFStringEncodingASCII) : NULL,
-	 &results);
+        CFStringRef cf_title   = CFSTRINGIFY(title);
+        CFStringRef cf_message = CFSTRINGIFY(message);
+        CFStringRef cf_button1 = NULL;
+        CFStringRef cf_button2 = NULL;
+        CFStringRef cf_button3 = NULL;
+
+        if (button1 != NULL)
+            cf_button1 = CFSTRINGIFY(button1);
+        if (button2 != NULL)
+            cf_button2 = CFSTRINGIFY(button2);
+        if (button3 != NULL)
+            cf_button3 = CFSTRINGIFY(button3);
+
+        CFOptionFlags alert_flags = kCFUserNotificationStopAlertLevel | kCFUserNotificationNoDefaultButtonFlag;
+
+	CFUserNotificationDisplayAlert(0, alert_flags, NULL, NULL, NULL, cf_title, cf_message,
+                                       cf_button1, cf_button2, cf_button3, &results);
+
+        if (cf_button1 != NULL)
+           CFRelease(cf_button1);
+        if (cf_button2 != NULL)
+           CFRelease(cf_button2);
+        if (cf_button3 != NULL)
+           CFRelease(cf_button3);
+        CFRelease(cf_message);
+        CFRelease(cf_title);
 
 	return (int)results;
 }
diff --git a/src/sdl/macosx/mac_resources.c b/src/sdl/macosx/mac_resources.c
index 706c5e7fc1effb2c5a46abed2ca36dd3e1a4a394..d67b925802666207160e9d75d3d0179042ca34ff 100644
--- a/src/sdl/macosx/mac_resources.c
+++ b/src/sdl/macosx/mac_resources.c
@@ -12,11 +12,20 @@ void OSX_GetResourcesPath(char * buffer)
         const int BUF_SIZE = 256; // because we somehow always know that
 
         CFURLRef appUrlRef = CFBundleCopyBundleURL(mainBundle);
-        CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
+        CFStringRef macPath;
+        if (appUrlRef != NULL)
+            macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
+        else
+            macPath = NULL;
 
-        const char* rawPath = CFStringGetCStringPtr(macPath, kCFStringEncodingASCII);
- 
-        if (CFStringGetLength(macPath) + strlen("/Contents/Resources") < BUF_SIZE)
+        const char* rawPath;
+
+        if (macPath != NULL)
+            rawPath = CFStringGetCStringPtr(macPath, kCFStringEncodingASCII);
+        else
+            rawPath = NULL;
+
+        if (rawPath != NULL && (CFStringGetLength(macPath) + strlen("/Contents/Resources") < BUF_SIZE))
         {
             strcpy(buffer, rawPath);
             strcat(buffer, "/Contents/Resources");
@@ -25,5 +34,4 @@ void OSX_GetResourcesPath(char * buffer)
         CFRelease(macPath);
         CFRelease(appUrlRef);
     }
-    CFRelease(mainBundle);
 }