Commit 460ab654 authored by Erwan Tulou's avatar Erwan Tulou Committed by Rémi Duraffort

core: correct memory leak

var_Change with VLC_VAR_SETVALUE showed a memory leak when dealing with a STRING variable.
The pf_dup function must not be called directy with a parameter passed by the caller.
otherwise, a reference is lost (memory leak)
Signed-off-by: default avatarRémi Duraffort <ivoire@videolan.org>
parent 93c2522b
......@@ -407,6 +407,7 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
int i_var, i;
variable_t *p_var;
vlc_value_t oldval;
vlc_value_t newval;
assert( p_this );
......@@ -562,13 +563,14 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
break;
case VLC_VAR_SETVALUE:
/* Duplicate data if needed */
p_var->ops->pf_dup( p_val );
newval = *p_val;
p_var->ops->pf_dup( &newval );
/* Backup needed stuff */
oldval = p_var->val;
/* Check boundaries and list */
CheckValue( p_var, p_val );
CheckValue( p_var, &newval );
/* Set the variable */
p_var->val = *p_val;
p_var->val = newval;
/* Free data if needed */
p_var->ops->pf_free( &oldval );
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment