[vlc-commits] commit: Lua: Avoid segmentation fault on recv() fail (Srikanth Raju )

git at videolan.org git at videolan.org
Sat Mar 20 18:34:44 CET 2010


vlc | branch: master | Srikanth Raju <srikiraju at gmail.com> | Thu Mar 11 21:16:58 2010 +0530| [14707cbaca9fa2961a00c563f14a5f6a44291a4d] | committer: Jean-Philippe André 

Lua: Avoid segmentation fault on recv() fail

Signed-off-by: Jean-Philippe André <jpeg at videolan.org>

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

 modules/misc/lua/libs/net.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/modules/misc/lua/libs/net.c b/modules/misc/lua/libs/net.c
index b8d3091..b5227d2 100644
--- a/modules/misc/lua/libs/net.c
+++ b/modules/misc/lua/libs/net.c
@@ -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;
 }
 
 /*****************************************************************************



More information about the vlc-commits mailing list