Skip to content

Commit

Permalink
Avoiding arithmetic ops with NULL pointer in nxt_unit_mmap_get
Browse files Browse the repository at this point in the history
Found by UndefinedBehaviorSanitizer.
  • Loading branch information
andrey-zelenkov committed Jan 31, 2024
1 parent e059674 commit eabd7c7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/nxt_unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -3506,6 +3506,10 @@ nxt_unit_mmap_get(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port,

outgoing_size = lib->outgoing.size;

if (nxt_slow_path(outgoing_size == 0)) {
goto skip;
}

mm_end = lib->outgoing.elts + outgoing_size;

for (mm = lib->outgoing.elts; mm < mm_end; mm++) {
Expand Down Expand Up @@ -3556,6 +3560,8 @@ nxt_unit_mmap_get(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port,
hdr->oosm = 1;
}

skip:

if (outgoing_size >= lib->shm_mmap_limit) {
/* Cannot allocate more shared memory. */
pthread_mutex_unlock(&lib->outgoing.mutex);
Expand Down

0 comments on commit eabd7c7

Please sign in to comment.