[vlc-devel] [RFC 15/38] lua/libs: removed usage of xmalloc

Filip Roséen filip at videolabs.io
Mon Jun 27 13:43:26 CEST 2016


---
 modules/lua/libs/net.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/modules/lua/libs/net.c b/modules/lua/libs/net.c
index 3368c0d..502cab5 100644
--- a/modules/lua/libs/net.c
+++ b/modules/lua/libs/net.c
@@ -337,8 +337,15 @@ static int vlclua_net_poll( lua_State *L )
         lua_pop( L, 1 );
     }
 
-    struct pollfd *p_fds = xmalloc( i_fds * sizeof( *p_fds ) );
-    int *luafds = xmalloc( i_fds * sizeof( *luafds ) );
+    struct pollfd *p_fds = malloc( i_fds * sizeof( *p_fds ) );
+    int *luafds = malloc( i_fds * sizeof( *luafds ) );
+
+    if( unlikely( !p_fds || !luafds ) )
+    {
+        free( luafds );
+        free( p_fds );
+        return VLC_ENOMEM;
+    }
 
     lua_pushnil( L );
     for( int i = 0; lua_next( L, 1 ); i++ )
-- 
2.9.0



More information about the vlc-devel mailing list