[vlc-commits] macosx: fix crash in str_format_meta

David Fuhrmann git at videolan.org
Thu May 7 20:00:39 CEST 2015


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

macosx: fix crash in str_format_meta

(cherry picked from commit e823a595a8aa041de17e23d8f84bcb90d5d48702)
Signed-off-by: David Fuhrmann <dfuhrmann at videolan.org>

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

 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 1fc4d6e..b749512 100644
--- a/modules/gui/macosx/CoreInteraction.m
+++ b/modules/gui/macosx/CoreInteraction.m
@@ -258,12 +258,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 875c71f..b712413 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