summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_job.c
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2023-03-14 17:31:48 +0000
committerAndrew Clayton <a.clayton@nginx.com>2023-04-03 14:53:04 +0100
commit8a9e078e5427e2b72e178740f25cbcebb780b225 (patch)
tree33307a850604a63632af6cf350fc58909cc5cfe3 /src/nxt_job.c
parent22993fe41a65b7fc4215f2378e1251c790db0ecc (diff)
downloadunit-8a9e078e5427e2b72e178740f25cbcebb780b225.tar.gz
unit-8a9e078e5427e2b72e178740f25cbcebb780b225.tar.bz2
Prevent a possible NULL de-reference in nxt_job_create().
We allocate 'job' we then have a check if it's not NULL and do stuff with it, but then we accessed it outside this check. Simply return if job is NULL. Reviewed-by: Alejandro Colomar <alx@nginx.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to '')
-rw-r--r--src/nxt_job.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/nxt_job.c b/src/nxt_job.c
index 995fd89b..56073953 100644
--- a/src/nxt_job.c
+++ b/src/nxt_job.c
@@ -32,12 +32,14 @@ nxt_job_create(nxt_mp_t *mp, size_t size)
cache_size = size;
}
- if (nxt_fast_path(job != NULL)) {
- job->cache_size = (uint16_t) cache_size;
- job->mem_pool = mp;
- nxt_job_set_name(job, "job");
+ if (nxt_slow_path(job == NULL)) {
+ return NULL;
}
+ job->cache_size = (uint16_t) cache_size;
+ job->mem_pool = mp;
+ nxt_job_set_name(job, "job");
+
/* Allow safe nxt_queue_remove() in nxt_job_destroy(). */
nxt_queue_self(&job->link);