[vlc-devel] commit: lua: fix potential leak (and missing unlock). ( Rémi Duraffort )

git version control git at videolan.org
Tue Jan 26 22:55:54 CET 2010


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Tue Jan 26 22:38:37 2010 +0100| [a67d563f100cbdf4ec7fe2f23c89b829b226f2d9] | committer: Rémi Duraffort 

lua: fix potential leak (and missing unlock).

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

 modules/misc/lua/extension_thread.c |    7 ++++++-
 modules/misc/lua/libs/dialog.c      |    3 +++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/modules/misc/lua/extension_thread.c b/modules/misc/lua/extension_thread.c
index 2ccfdbb..5661211 100644
--- a/modules/misc/lua/extension_thread.c
+++ b/modules/misc/lua/extension_thread.c
@@ -222,7 +222,12 @@ int PushCommand( extension_t *p_ext,
         case CMD_TRIGGERMENU:
             {
                 int *pi = malloc( sizeof( int ) );
-                if( !pi ) return VLC_ENOMEM;
+                if( !pi )
+                {
+                    free( cmd );
+                    vlc_mutex_unlock( &p_ext->p_sys->command_lock );
+                    return VLC_ENOMEM;
+                }
                 *pi = va_arg( args, int );
                 cmd->data[0] = pi;
             }
diff --git a/modules/misc/lua/libs/dialog.c b/modules/misc/lua/libs/dialog.c
index e463e30..d0702c3 100644
--- a/modules/misc/lua/libs/dialog.c
+++ b/modules/misc/lua/libs/dialog.c
@@ -163,7 +163,10 @@ static int vlclua_dialog_create( lua_State *L )
     lua_getglobal( L, "vlc" );
     lua_getfield( L, -1, "__dialog" );
     if( lua_topointer( L, lua_gettop( L ) ) != NULL )
+    {
+        free( p_dlg );
         return luaL_error( L, "Only one dialog allowed per extension!" );
+    }
 
     p_dlg->p_object = p_this;
     p_dlg->psz_title = strdup( psz_title );




More information about the vlc-devel mailing list