From b82297c446e262e0dab45c20754cf2ed0e8ae634 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. Reviewed-by: Andrew Clayton --- 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);