Explorar o código

Fix lua_websocket_new in case the Lua script rejects the connection

bel %!s(int64=10) %!d(string=hai) anos
pai
achega
020951c8de
Modificáronse 1 ficheiros con 2 adicións e 3 borrados
  1. 2 3
      src/mod_lua.inl

+ 2 - 3
src/mod_lua.inl

@@ -1266,13 +1266,12 @@ static void * lua_websocket_new(const char * script, struct mg_connection *conn)
     if (!ok) {
         /* Remove from ws connection list. */
         /* TODO: Check if list entry and Lua state needs to be deleted (see websocket_close). */
-        (*shared_websock_list)->ws.conn[--(ws->references)] = 0;
-        ws = NULL;
+        (*shared_websock_list)->ws.conn[--(ws->references)] = 0;    
     }
 
     (void)pthread_mutex_unlock(&(ws->ws_mutex));
 
-    return (void*)ws;
+    return ok ? (void*)ws : NULL;
 }
 
 static int lua_websocket_data(struct mg_connection * conn, void *ws_arg, int bits, char *data, size_t data_len)