Ver código fonte

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 anos atrás
pai
commit
1fd406d476
1 arquivos alterados com 1 adições e 1 exclusões
  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);
 }