[vlc-commits] lua: fix incorrect assertion in playlist file read
Rémi Denis-Courmont
git at videolan.org
Tue Apr 18 22:43:34 CEST 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Apr 18 23:42:50 2017 +0300| [0eafef0b81d1cf937277e086cb92caf142fec509] | committer: Rémi Denis-Courmont
lua: fix incorrect assertion in playlist file read
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0eafef0b81d1cf937277e086cb92caf142fec509
---
modules/lua/demux.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/modules/lua/demux.c b/modules/lua/demux.c
index 92224961d2..c66a739b72 100644
--- a/modules/lua/demux.c
+++ b/modules/lua/demux.c
@@ -66,15 +66,17 @@ static int vlclua_demux_peek( lua_State *L )
static int vlclua_demux_read( lua_State *L )
{
stream_t *s = (stream_t *)vlclua_get_this(L);
- const uint8_t *p_read;
int n = luaL_checkint( L, 1 );
- ssize_t val = vlc_stream_Peek(s->p_source, &p_read, n);
+ char *buf = malloc(n);
- if (val > 0)
+ if (buf != NULL)
{
- lua_pushlstring(L, (const char *)p_read, val);
- int i_seek = vlc_stream_Read(s->p_source, NULL, val);
- assert(val == i_seek );
+ ssize_t val = vlc_stream_Read(s->p_source, buf, n);
+ if (val > 0)
+ lua_pushlstring(L, buf, val);
+ else
+ lua_pushnil( L );
+ free(buf);
}
else
lua_pushnil( L );
More information about the vlc-commits
mailing list