[vlc-devel] commit: core: correct memory leak (Erwan Tulou )

git version control git at videolan.org
Tue Jan 5 18:25:43 CET 2010


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Sat Jan  2 23:09:36 2010 +0100| [460ab654839e45e330086295ed3be7b3913fa33f] | committer: 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: Rémi Duraffort <ivoire at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=460ab654839e45e330086295ed3be7b3913fa33f
---

 src/misc/variables.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/misc/variables.c b/src/misc/variables.c
index d681162..a6e61a9 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -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;




More information about the vlc-devel mailing list