[vlc-commits] lua: fix memory leak when getting/inherting string variable
Rémi Denis-Courmont
git at videolan.org
Wed Nov 16 16:48:51 CET 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Nov 16 17:48:37 2016 +0200| [a6fd99e4e8efba957e457a864fcdbf89298817cf] | committer: Rémi Denis-Courmont
lua: fix memory leak when getting/inherting string variable
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a6fd99e4e8efba957e457a864fcdbf89298817cf
---
modules/lua/libs/variables.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/modules/lua/libs/variables.c b/modules/lua/libs/variables.c
index 2ee8370..9957a68 100644
--- a/modules/lua/libs/variables.c
+++ b/modules/lua/libs/variables.c
@@ -128,7 +128,10 @@ static int vlclua_var_inherit( lua_State *L )
return 0;
lua_pop( L, 2 );
- return vlclua_pushvalue( L, i_type, val );
+ vlclua_pushvalue( L, i_type, val );
+ if( i_type == VLC_VAR_STRING )
+ free( val.psz_string );
+ return 1;
}
static int vlclua_var_get( lua_State *L )
@@ -142,7 +145,10 @@ static int vlclua_var_get( lua_State *L )
return 0;
lua_pop( L, 2 );
- return vlclua_pushvalue( L, i_type, val );
+ vlclua_pushvalue( L, i_type, val );
+ if( i_type == VLC_VAR_STRING )
+ free( val.psz_string );
+ return 1;
}
static int vlclua_var_set( lua_State *L )
More information about the vlc-commits
mailing list