variables: fix a potential crash/double free.
authorRémi Duraffort <ivoire@videolan.org>
Tue, 19 May 2009 21:33:00 +0000 (23:33 +0200)
committerRémi Duraffort <ivoire@videolan.org>
Tue, 19 May 2009 21:33:00 +0000 (23:33 +0200)
Indeed, giving a NULL to var_Change(VLC_VAR_SETSTRING) will lead to a crash the
next time this variable is used.

src/misc/variables.c

index 1242431..f8bf3d8 100644 (file)
@@ -623,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;