[vlc-commits] macosx: fix crash in str_format_meta

David Fuhrmann git at videolan.org
Thu May 7 19:59:51 CEST 2015


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Thu May  7 19:29:51 2015 +0200| [e823a595a8aa041de17e23d8f84bcb90d5d48702] | committer: David Fuhrmann

macosx: fix crash in str_format_meta

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e823a595a8aa041de17e23d8f84bcb90d5d48702
---

 modules/gui/macosx/CoreInteraction.m |   12 +++++++-----
 modules/gui/macosx/MainWindow.m      |   12 +++++++-----
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/modules/gui/macosx/CoreInteraction.m b/modules/gui/macosx/CoreInteraction.m
index 5d13a5f..a9a7c76 100644
--- a/modules/gui/macosx/CoreInteraction.m
+++ b/modules/gui/macosx/CoreInteraction.m
@@ -248,12 +248,14 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
         return nil;
     }
 
-    NSString *o_name;
+    NSString *o_name = @"";
     char *format = var_InheritString(VLCIntf, "input-title-format");
-    char *formated = str_format_meta(p_input, format);
-    free(format);
-    o_name = [NSString stringWithUTF8String:formated];
-    free(formated);
+    if (format) {
+        char *formated = str_format_meta(p_input, format);
+        free(format);
+        o_name = toNSStr(formated);
+        free(formated);
+    }
 
     NSURL * o_url = [NSURL URLWithString:[NSString stringWithUTF8String:psz_uri]];
     free(psz_uri);
diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index 94a2301..6655857 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -695,14 +695,16 @@ static VLCMainWindow *_o_sharedInstance = nil;
     input_thread_t * p_input;
     p_input = pl_CurrentInput(VLCIntf);
     if (p_input) {
-        NSString *aString;
+        NSString *aString = @"";
 
         if (!config_GetPsz(VLCIntf, "video-title")) {
             char *format = var_InheritString(VLCIntf, "input-title-format");
-            char *formated = str_format_meta(p_input, format);
-            free(format);
-            aString = [NSString stringWithUTF8String:formated];
-            free(formated);
+            if (format) {
+                char *formated = str_format_meta(p_input, format);
+                free(format);
+                aString = toNSStr(formated);
+                free(formated);
+            }
         } else
             aString = [NSString stringWithUTF8String:config_GetPsz(VLCIntf, "video-title")];
 



More information about the vlc-commits mailing list