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: Rémi Duraffort <ivoire@videolan.org>
int i_var, i;
variable_t *p_var;
vlc_value_t oldval;
+ vlc_value_t newval;
assert( p_this );
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;