From dd701fb449259c5edbc4302ad8556762f1a30b76 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Wed, 31 Jan 2024 15:24:06 +0000 Subject: 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(+) (limited to 'src') diff --git a/src/nxt_unit.c b/src/nxt_unit.c index 1fc9acd8..576c751d 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 @@ retry: goto retry; } +skip: + *c = 0; hdr = nxt_unit_new_mmap(ctx, port, *n); -- cgit