]> git.sesse.net Git - vlc/blobdiff - src/misc/variables.c
variables: fix a potential crash/double free.
[vlc] / src / misc / variables.c
index 26d79d0ec92fc23dfd311f0172412ae0362c6a77..f8bf3d8e951760f77f82c2bac06fa683677cc079 100644 (file)
@@ -68,7 +68,10 @@ static int CmpAddress( vlc_value_t v, vlc_value_t w ) { return v.p_address == w.
  * Local duplication functions, and local deallocation functions
  *****************************************************************************/
 static void DupDummy( vlc_value_t *p_val ) { (void)p_val; /* unused */ }
-static void DupString( vlc_value_t *p_val ) { if( p_val->psz_string ) p_val->psz_string = strdup( p_val->psz_string ); }
+static void DupString( vlc_value_t *p_val )
+{
+    p_val->psz_string = strdup( p_val->psz_string ? p_val->psz_string :  "" );
+}
 
 static void DupList( vlc_value_t *p_val )
 {
@@ -620,6 +623,8 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
             free( p_var->psz_text );
             if( p_val && p_val->psz_string )
                 p_var->psz_text = strdup( p_val->psz_string );
+            else
+                p_val->psz_text = NULL;
             break;
         case VLC_VAR_GETTEXT:
             p_val->psz_string = NULL;
@@ -1406,8 +1411,10 @@ static int InheritValue( vlc_object_t *p_this, const char *psz_name,
             /* Duplicate value if needed */
             p_var->ops->pf_dup( p_val );
 
-            msg_Dbg( p_this, "Inherited value for var %s from object %s", psz_name ? : "(null)",
-                p_this->psz_object_name ? : "(Unknown)" ) ;
+            /*msg_Dbg( p_this, "Inherited value for var %s from object %s",
+                     psz_name ? psz_name : "(null)",
+                     p_this->psz_object_name
+                         ? p_this->psz_object_name : "(Unknown)" );*/
             return VLC_SUCCESS;
         }
         else if ( p_this->p_parent ) /* We are still not there */
@@ -1462,11 +1469,12 @@ static int InheritValue( vlc_object_t *p_this, const char *psz_name,
             break;
         }
         default:
-            msg_Warn( p_this, "Could not inherit value for var %s from config. Invalid Type", psz_name ) ;
+            msg_Warn( p_this, "Could not inherit value for var %s "
+                              "from config. Invalid Type", psz_name );
             return VLC_ENOOBJ;
             break;
     }
-    msg_Dbg( p_this, "Inherited value for var %s from config", psz_name ) ;
+    /*msg_Dbg( p_this, "Inherited value for var %s from config", psz_name );*/
     return VLC_SUCCESS;
 }