[vlc-commits] lua_xml: fix read of non-initialized pointers.

Rémi Duraffort git at videolan.org
Sun Jan 23 11:25:36 CET 2011


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Sun Jan 23 11:25:16 2011 +0100| [5475749dd0134214fecd0751c2d3dae4d47d4522] | committer: Rémi Duraffort

lua_xml: fix read of non-initialized pointers.

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

 modules/misc/lua/libs/xml.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/modules/misc/lua/libs/xml.c b/modules/misc/lua/libs/xml.c
index 74f05f9..f8b0afe 100644
--- a/modules/misc/lua/libs/xml.c
+++ b/modules/misc/lua/libs/xml.c
@@ -128,7 +128,14 @@ static int vlclua_xml_reader_next_node( lua_State *L )
 {
     xml_reader_t *p_reader = *(xml_reader_t**)luaL_checkudata( L, 1, "xml_reader" );
     const char *psz_name;
-    lua_pushinteger( L, xml_ReaderNextNode( p_reader, &psz_name ) );
+    int i_type = xml_ReaderNextNode( p_reader, &psz_name );
+    if( i_type <= 0 )
+    {
+        lua_pushinteger( L, 0 );
+        return 1;
+    }
+
+    lua_pushinteger( L, i_type );
     lua_pushstring( L, psz_name );
     return 2;
 }
@@ -137,8 +144,11 @@ static int vlclua_xml_reader_next_attr( lua_State *L )
 {
     xml_reader_t *p_reader = *(xml_reader_t**)luaL_checkudata( L, 1, "xml_reader" );
     const char *psz_value;
+    const char *psz_name = xml_ReaderNextAttr( p_reader, &psz_value );
+    if( !psz_name )
+        return 0;
 
-    lua_pushstring( L, xml_ReaderNextAttr( p_reader, &psz_value ) );
+    lua_pushstring( L, psz_name );
     lua_pushstring( L, psz_value );
     return 2;
 }



More information about the vlc-commits mailing list