Releasing init struct in case of errors.

Found by Coverity (CID 349485).
This commit is contained in:
Tiago Natel
2019-09-20 13:12:04 +00:00
parent 7f389c814a
commit 20628c74fa

View File

@@ -661,7 +661,7 @@ nxt_main_start_worker_process(nxt_task_t *task, nxt_runtime_t *rt,
ret = nxt_user_cred_get(task, init->user_cred, group); ret = nxt_user_cred_get(task, init->user_cred, group);
if (ret != NXT_OK) { if (ret != NXT_OK) {
return NXT_ERROR; goto fail;
} }
} else { } else {
@@ -670,7 +670,7 @@ nxt_main_start_worker_process(nxt_task_t *task, nxt_runtime_t *rt,
{ {
nxt_alert(task, "cannot set user \"%V\" for app \"%V\": " nxt_alert(task, "cannot set user \"%V\" for app \"%V\": "
"missing capabilities", &app_conf->user, &app_conf->name); "missing capabilities", &app_conf->user, &app_conf->name);
return NXT_ERROR; goto fail;
} }
if (app_conf->group.length > 0 if (app_conf->group.length > 0
@@ -680,7 +680,7 @@ nxt_main_start_worker_process(nxt_task_t *task, nxt_runtime_t *rt,
nxt_alert(task, "cannot set group \"%V\" for app \"%V\": " nxt_alert(task, "cannot set group \"%V\" for app \"%V\": "
"missing capabilities", &app_conf->group, "missing capabilities", &app_conf->group,
&app_conf->name); &app_conf->name);
return NXT_ERROR; goto fail;
} }
last = nxt_pointer_to(init, sizeof(nxt_process_init_t)); last = nxt_pointer_to(init, sizeof(nxt_process_init_t));
@@ -702,10 +702,16 @@ nxt_main_start_worker_process(nxt_task_t *task, nxt_runtime_t *rt,
ret = nxt_init_set_isolation(task, init, app_conf->isolation); ret = nxt_init_set_isolation(task, init, app_conf->isolation);
if (nxt_slow_path(ret != NXT_OK)) { if (nxt_slow_path(ret != NXT_OK)) {
return NXT_ERROR; goto fail;
} }
return nxt_main_create_worker_process(task, rt, init); return nxt_main_create_worker_process(task, rt, init);
fail:
nxt_free(init);
return NXT_ERROR;
} }