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.
This commit is contained in:
Sergey Kandaurov 2019-02-21 16:30:59 +03:00
parent 499096a55a
commit 3280b826e3

View file

@ -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)); memcpy(&fd, CMSG_DATA(cm), sizeof(int));
} }
nxt_queue_init(&incoming_buf);
if (nxt_slow_path(buf_size < sizeof(nxt_port_msg_t))) { if (nxt_slow_path(buf_size < sizeof(nxt_port_msg_t))) {
nxt_unit_warn(ctx, "message too small (%d bytes)", (int) buf_size); nxt_unit_warn(ctx, "message too small (%d bytes)", (int) buf_size);
goto fail; 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) { if (port_msg->mmap) {
nxt_queue_init(&incoming_buf);
if (nxt_unit_mmap_read(ctx, &recv_msg, &incoming_buf) != NXT_UNIT_OK) { if (nxt_unit_mmap_read(ctx, &recv_msg, &incoming_buf) != NXT_UNIT_OK) {
goto fail; goto fail;
} }