Skip to content

Commit

Permalink
Avoiding arithmetic ops with NULL pointer in nxt_port_mmap_get
Browse files Browse the repository at this point in the history
Can be reproduced by test/test_settings.py::test_settings_send_timeout
with enabled UndefinedBehaviorSanitizer.
  • Loading branch information
andrey-zelenkov committed Feb 22, 2024
1 parent 589b50c commit 7d10bd5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/nxt_port_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@ nxt_port_mmap_get(nxt_task_t *task, nxt_port_mmaps_t *mmaps, nxt_chunk_id_t *c,

nxt_thread_mutex_lock(&mmaps->mutex);

if (nxt_slow_path(mmaps->elts == NULL)) {
goto end;
}

end_port_mmap = mmaps->elts + mmaps->size;

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

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

end:

*c = 0;
mmap_handler = nxt_port_new_port_mmap(task, mmaps, tracking, n);

Expand Down

0 comments on commit 7d10bd5

Please sign in to comment.