mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-19 19:40:56 +00:00
Checking malloc return code in worker_thread()
This commit is contained in:
1 parent
cda24d94fb
commit
a6678814af
1 file changed
+4
-1
+4
-1
@@ -3956,9 +3956,12 @@ static void worker_thread(struct mg_context *ctx) {
|
|||||||
int buf_size = atoi(ctx->config[MAX_REQUEST_SIZE]);
|
int buf_size = atoi(ctx->config[MAX_REQUEST_SIZE]);
|
||||||
|
|
||||||
conn = (struct mg_connection *) calloc(1, sizeof(*conn) + buf_size);
|
conn = (struct mg_connection *) calloc(1, sizeof(*conn) + buf_size);
|
||||||
|
if (conn == NULL) {
|
||||||
|
cry(fc(ctx), "%s", "Cannot create new connection struct, OOM");
|
||||||
|
return;
|
||||||
|
}
|
||||||
conn->buf_size = buf_size;
|
conn->buf_size = buf_size;
|
||||||
conn->buf = (char *) (conn + 1);
|
conn->buf = (char *) (conn + 1);
|
||||||
assert(conn != NULL);
|
|
||||||
|
|
||||||
// Call consume_socket() even when ctx->stop_flag > 0, to let it signal
|
// Call consume_socket() even when ctx->stop_flag > 0, to let it signal
|
||||||
// sq_empty condvar to wake up the master waiting in produce_socket()
|
// sq_empty condvar to wake up the master waiting in produce_socket()
|
||||||
|
|||||||
Reference in new issue
Block a user