Skip to content

Commit 2b032b6

Browse files
authored
Merge pull request #100 from jandubois/fix-crashes
Fix crashes and -p option
2 parents bd8bf26 + 160af6f commit 2b032b6

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

cli.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct cli_options *cli_options_parse(int argc, char *argv[]) {
100100
{0, 0, 0, 0},
101101
};
102102
int opt = 0;
103-
while ((opt = getopt_long(argc, argv, "hvp", longopts, NULL)) != -1) {
103+
while ((opt = getopt_long(argc, argv, "hvp:", longopts, NULL)) != -1) {
104104
switch (opt) {
105105
case CLI_OPT_SOCKET_GROUP:
106106
res->socket_group = strdup(optarg);

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)