# define VIR_FROM_THIS VIR_FROM_NONE
struct Arguments {
- int readfds[3];
+ int *readfds;
int numreadfds;
bool daemonize_check;
bool close_stdin;
if (!(args = calloc(1, sizeof(*args))))
goto cleanup;
+ if (!(args->readfds = calloc(1, sizeof(*args->readfds))))
+ goto cleanup;
+
args->numreadfds = 1;
args->readfds[0] = STDIN_FILENO;
if (STREQ(argv[i - 1], "--readfd")) {
char c;
+ args->readfds = realloc(args->readfds,
+ (args->numreadfds + 1) *
+ sizeof(*args->readfds));
+ if (!args->readfds)
+ goto cleanup;
+
if (1 != sscanf(argv[i], "%u%c",
&args->readfds[args->numreadfds++], &c)) {
printf("Could not parse fd %s\n", argv[i]);
if (ret == 0)
return args;
- free(args);
+ if (args) {
+ if (args->readfds)
+ free(args->readfds);
+ free(args);
+ }
+
return NULL;
}
ret = EXIT_SUCCESS;
cleanup:
- if (args)
+ if (args) {
+ if (args->readfds)
+ free(args->readfds);
free(args);
+ }
if (log)
fclose(log);
return ret;