Skip to content

Commit 160af6f

Browse files
committed
Make sure dispatch queues are only released if they have been created
Don't jump over the initialization of the state structure. dispatch_release() cannot be called with a NULL argument. Signed-off-by: Jan Dubois <jan.dubois@suse.com>
1 parent 923215e commit 160af6f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

main.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ int main(int argc, char *argv[]) {
371371
int rc = 1, listen_fd = -1;
372372
__block interface_ref iface = NULL;
373373

374+
struct state state;
375+
memset(&state, 0, sizeof(state));
376+
374377
struct cli_options *cliopt = cli_options_parse(argc, argv);
375378
assert(cliopt != NULL);
376379
if (geteuid() != 0) {
@@ -409,8 +412,6 @@ int main(int argc, char *argv[]) {
409412
goto done;
410413
}
411414

412-
struct state state;
413-
memset(&state, 0, sizeof(state));
414415
state.sem = dispatch_semaphore_create(1);
415416

416417
// Queue for vm connections, allowing processing vms requests in parallel.
@@ -460,8 +461,10 @@ int main(int argc, char *argv[]) {
460461
unlink(cliopt->pidfile);
461462
close(pid_fd);
462463
}
463-
dispatch_release(state.vms_queue);
464-
dispatch_release(state.host_queue);
464+
if (state.vms_queue != NULL)
465+
dispatch_release(state.vms_queue);
466+
if (state.host_queue != NULL)
467+
dispatch_release(state.host_queue);
465468
cli_options_destroy(cliopt);
466469
return rc;
467470
}

0 commit comments

Comments
 (0)