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:
parent
22993fe41a
commit
8a9e078e54
1 changed files with 6 additions and 4 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue