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>
This commit is contained in:
@@ -32,11 +32,13 @@ nxt_job_create(nxt_mp_t *mp, size_t size)
|
|||||||
cache_size = size;
|
cache_size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nxt_fast_path(job != NULL)) {
|
if (nxt_slow_path(job == NULL)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
job->cache_size = (uint16_t) cache_size;
|
job->cache_size = (uint16_t) cache_size;
|
||||||
job->mem_pool = mp;
|
job->mem_pool = mp;
|
||||||
nxt_job_set_name(job, "job");
|
nxt_job_set_name(job, "job");
|
||||||
}
|
|
||||||
|
|
||||||
/* Allow safe nxt_queue_remove() in nxt_job_destroy(). */
|
/* Allow safe nxt_queue_remove() in nxt_job_destroy(). */
|
||||||
nxt_queue_self(&job->link);
|
nxt_queue_self(&job->link);
|
||||||
|
|||||||
Reference in New Issue
Block a user