[vlc-commits] macosx: fix crash in str_format_meta

2015-05-07 Thread David Fuhrmann
vlc/vlc-2.2 | branch: master | David Fuhrmann  | 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 

> 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")];
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] macosx: fix crash in str_format_meta

2015-05-07 Thread David Fuhrmann
vlc | branch: master | David Fuhrmann  | 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")];
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits