summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2024-01-31 15:24:06 +0000
committerandrey-zelenkov <xim.andrew@gmail.com>2024-03-11 16:51:35 +0000
commitdd701fb449259c5edbc4302ad8556762f1a30b76 (patch)
tree327a13ef397c29a1eca5fe64570d1c7a463c8511
parentc9461a6ba849c69b0aad4dd5791c65d582946b8d (diff)
downloadunit-dd701fb449259c5edbc4302ad8556762f1a30b76.tar.gz
unit-dd701fb449259c5edbc4302ad8556762f1a30b76.tar.bz2
Avoiding arithmetic ops with NULL pointer in nxt_unit_mmap_get
Found by UndefinedBehaviorSanitizer. Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
-rw-r--r--src/nxt_unit.c6
1 files changed, 6 insertions, 0 deletions
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);