From da0802ebdddb9ba5d1105b404336d68c82102e0b Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Wed, 31 Jan 2024 15:24:06 +0000 Subject: [PATCH] Avoiding arithmetic ops with NULL pointer in nxt_unit_mmap_get Found by UndefinedBehaviorSanitizer. --- src/nxt_unit.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/nxt_unit.c b/src/nxt_unit.c index 1fc9acd8d..576c751de 100644 --- a/src/nxt_unit.c +++ b/src/nxt_unit.c @@ -3502,6 +3502,10 @@ nxt_unit_mmap_get(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port, pthread_mutex_lock(&lib->outgoing.mutex); + if (nxt_slow_path(lib->outgoing.elts == NULL)) { + goto skip; + } + retry: outgoing_size = lib->outgoing.size; @@ -3598,6 +3602,8 @@ nxt_unit_mmap_get(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port, goto retry; } +skip: + *c = 0; hdr = nxt_unit_new_mmap(ctx, port, *n);