Commit 14707cba authored by Srikanth Raju's avatar Srikanth Raju Committed by Jean-Philippe André

Lua: Avoid segmentation fault on recv() fail

Signed-off-by: default avatarJean-Philippe André <jpeg@videolan.org>
parent 2bb90c75
......@@ -185,8 +185,13 @@ static int vlclua_net_recv( lua_State *L )
size_t i_len = luaL_optint( L, 2, 1 );
char psz_buffer[i_len];
i_len = recv( i_fd, psz_buffer, i_len, 0 );
lua_pushlstring( L, psz_buffer, i_len );
return 1;
if( i_len > 0 )
{
lua_pushlstring( L, psz_buffer, i_len );
return 1;
}
else
return 0;
}
/*****************************************************************************
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment