control/media_descriptor.c: Make sure we don't strdup a NULL ptr.
[vlc.git] / src / control / media_descriptor.c
index 1f6cb38..d5c076e 100644 (file)
@@ -57,7 +57,7 @@ libvlc_media_descriptor_t * libvlc_media_descriptor_new(
 
     if (!p_input_item)
     {
-        libvlc_exception_raise( ex, "Can't create md's input_item" );
+        libvlc_exception_raise( p_e, "Can't create md's input_item" );
         return NULL;
     }
 
@@ -75,13 +75,14 @@ libvlc_media_descriptor_t * libvlc_media_descriptor_new(
  **************************************************************************/
 libvlc_media_descriptor_t * libvlc_media_descriptor_new_from_input_item(
                                    libvlc_instance_t *p_instance,
-                                   input_item_t *p_input_item )
+                                   input_item_t *p_input_item,
+                                   libvlc_exception_t *p_e )
 {
     libvlc_media_descriptor_t * p_media_desc;
 
     if (!p_input_item)
     {
-        libvlc_exception_raise( ex, "No input item given" );
+        libvlc_exception_raise( p_e, "No input item given" );
         return NULL;
     }
 
@@ -135,12 +136,17 @@ char * libvlc_media_descriptor_get_meta( libvlc_media_descriptor_t *p_meta_desc,
                                          libvlc_exception_t *p_e )
 {
     char ** ppsz_meta;
+    char *ppz_meta;
 
     /* XXX: locking */
 
     preparse_if_needed( p_meta_desc );
 
     ppsz_meta = (char**)p_meta_desc->p_input_item->p_meta;
+    ppz_meta = ppsz_meta[ meta_conversion[e_meta] ];
+
+    if( !ppz_meta )
+        return NULL;
 
-    return strdup( ppsz_meta[ meta_conversion[e_meta] ] );
+    return strdup( ppz_meta );
 }