瀏覽代碼

Only free conn if in client context.

The worker_thread_run function will free the conn memory when it quits.
Freeing it in mg_close_connection frees it too early, causing a crash in
the worker_thread_run function as it reuses conn until the server quits
and asks the thread to quit.
Jacob Skillin 9 年之前
父節點
當前提交
1fd406d476
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/civetweb.c

+ 1 - 1
src/civetweb.c

@@ -10971,9 +10971,9 @@ mg_close_connection(struct mg_connection *conn)
 		}
 		mg_free(client_ctx->workerthreadids);
 		mg_free(client_ctx);
+		mg_free(conn);
 	}
 	(void)pthread_mutex_destroy(&conn->mutex);
-	mg_free(conn);
 }