From 3280b826e373bf88c16640cb434771df378bbb07 Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Thu, 21 Feb 2019 16:30:59 +0300 Subject: [PATCH] Initializing incoming buffer queue in a proper place. In case nxt_unit_tracking_read() failed, execution would jump to the error path, where it could try to release buffers from uninitialized yet incoming_buf queue. --- src/nxt_unit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nxt_unit.c b/src/nxt_unit.c index 24e51075..fa1fb1d5 100644 --- a/src/nxt_unit.c +++ b/src/nxt_unit.c @@ -541,6 +541,8 @@ nxt_unit_process_msg(nxt_unit_ctx_t *ctx, nxt_unit_port_id_t *port_id, memcpy(&fd, CMSG_DATA(cm), sizeof(int)); } + nxt_queue_init(&incoming_buf); + if (nxt_slow_path(buf_size < sizeof(nxt_port_msg_t))) { nxt_unit_warn(ctx, "message too small (%d bytes)", (int) buf_size); goto fail; @@ -570,8 +572,6 @@ nxt_unit_process_msg(nxt_unit_ctx_t *ctx, nxt_unit_port_id_t *port_id, } if (port_msg->mmap) { - nxt_queue_init(&incoming_buf); - if (nxt_unit_mmap_read(ctx, &recv_msg, &incoming_buf) != NXT_UNIT_OK) { goto fail; }