[vlc-commits] lua: sd: fix stack on error

Rémi Denis-Courmont git at videolan.org
Thu May 11 19:14:59 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed May 10 21:19:06 2017 +0300| [085165ec6bb831b78fb72fbcb4cb0d3de6a4b151] | committer: Rémi Denis-Courmont

lua: sd: fix stack on error

Do not leak two elements on the stack on error.

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

 modules/lua/libs/sd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/modules/lua/libs/sd.c b/modules/lua/libs/sd.c
index e69ccde37d..86ac9da49b 100644
--- a/modules/lua/libs/sd.c
+++ b/modules/lua/libs/sd.c
@@ -140,6 +140,8 @@ static input_item_t *vlclua_sd_create_item( services_discovery_t *p_sd,
        : psz_path;
 
     input_item_t *p_input = input_item_New( psz_path, psz_title );
+    lua_pop( L, 2 );
+
     if( unlikely(p_input == NULL) )
         return NULL;
 
@@ -148,9 +150,9 @@ static input_item_t *vlclua_sd_create_item( services_discovery_t *p_sd,
     char **ppsz_options = NULL;
     int i_options = 0;
 
-    lua_pushvalue( L, -3 );
+    lua_pushvalue( L, -1 );
     vlclua_read_options( p_sd, L, &i_options, &ppsz_options );
-    lua_pop( L, 3 );
+    lua_pop( L, 1 );
 
     input_item_AddOptions( p_input, i_options, (const char **)ppsz_options,
                            VLC_INPUT_OPTION_TRUSTED );



More information about the vlc-commits mailing list