浏览代码

Free context if initialization of TLS failed

bel 11 年之前
父节点
当前提交
82df56695c
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/civetweb.c

+ 2 - 1
src/civetweb.c

@@ -4784,7 +4784,7 @@ static void handle_websocket_request(struct mg_connection *conn, const char *pat
 {
     const char *version = mg_get_header(conn, "Sec-WebSocket-Version");
 #ifdef USE_LUA
-    int lua_websock, shared_lua_websock = 0; 
+    int lua_websock, shared_lua_websock = 0;
     /* TODO: A websocket script may be shared between several clients, allowing them to communicate
              directly instead of writing to a data base and polling the data base. */
 #endif
@@ -6332,6 +6332,7 @@ struct mg_context *mg_start(const struct mg_callbacks *callbacks,
     if (sTlsInit==0) {
         if (0 != pthread_key_create(&sTlsKey, NULL)) {
             mg_cry(fc(ctx), "Cannot initialize thread local storage");
+            free(ctx);
             return NULL;
         }
         sTlsInit++;