]> git.sesse.net Git - vlc/commitdiff
Fix a stack smash in the lua module (vlc.read).
authorJP Dinger <jpd@videolan.org>
Fri, 12 Jun 2009 13:05:56 +0000 (15:05 +0200)
committerJP Dinger <jpd@videolan.org>
Fri, 12 Jun 2009 13:09:08 +0000 (15:09 +0200)
modules/misc/lua/demux.c

index 140afa98f8dbc690aa12d49a10f0f882e510d358..d7f4445bf0ced0fdaf02b7567cdd43de7a4c8449 100644 (file)
@@ -28,6 +28,8 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_demux.h>
 #include <vlc_url.h>
@@ -72,10 +74,12 @@ static int vlclua_demux_peek( lua_State *L )
 static int vlclua_demux_read( lua_State *L )
 {
     demux_t *p_demux = (demux_t *)vlclua_get_this( L );
-    uint8_t *p_read;
+    const uint8_t *p_read;
     int n = luaL_checkint( L, 1 );
-    int i_read = stream_Read( p_demux->s, &p_read, n );
+    int i_read = stream_Peek( p_demux->s, &p_read, n );
     lua_pushlstring( L, (const char *)p_read, i_read );
+    int i_seek = stream_Read( p_demux->s, NULL, i_read );
+    assert(i_read==i_seek);
     return 1;
 }