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 Feb 21, 2024
1 parent 2d16d02 commit da0802e
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 @@ -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;
Expand Down Expand Up @@ -3598,6 +3602,8 @@ nxt_unit_mmap_get(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port,
goto retry;
}

skip:

*c = 0;
hdr = nxt_unit_new_mmap(ctx, port, *n);

Expand Down

0 comments on commit da0802e

Please sign in to comment.