Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Commit 264b375

Browse files
Avoiding arithmetic ops with NULL pointer in nxt_port_mmap_get
Can be reproduced by test/test_settings.py::test_settings_send_timeout with enabled UndefinedBehaviorSanitizer. Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
1 parent 7dcd6c0 commit 264b375

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/nxt_port_memory.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,10 @@ nxt_port_mmap_get(nxt_task_t *task, nxt_port_mmaps_t *mmaps, nxt_chunk_id_t *c,
454454

455455
nxt_thread_mutex_lock(&mmaps->mutex);
456456

457+
if (nxt_slow_path(mmaps->elts == NULL)) {
458+
goto end;
459+
}
460+
457461
end_port_mmap = mmaps->elts + mmaps->size;
458462

459463
for (port_mmap = mmaps->elts;
@@ -500,6 +504,8 @@ nxt_port_mmap_get(nxt_task_t *task, nxt_port_mmaps_t *mmaps, nxt_chunk_id_t *c,
500504

501505
/* TODO introduce port_mmap limit and release wait. */
502506

507+
end:
508+
503509
*c = 0;
504510
mmap_handler = nxt_port_new_port_mmap(task, mmaps, tracking, n);
505511

0 commit comments

Comments
 (0)