/* %n is replaced by the name of the running job */
expanded_name = str_replace(expanded_runtime, "%n", o->name);
+ free(expanded_runtime);
return expanded_name;
}
/* Creating the stderr & stdout output files */
outfd = open(outfilename, O_CREAT | O_WRONLY | O_TRUNC, 0644);
- if (!outfd) {
+ if (outfd < 0) {
log_err("fio: cannot open output file %s : %s\n",
outfilename, strerror(errno));
free(outfilename);
free(errfilename);
+ free(expanded_arguments);
return -1;
}
errfd = open(errfilename, O_CREAT | O_WRONLY | O_TRUNC, 0644);
- if (!errfd) {
+ if (errfd < 0) {
log_err("fio: cannot open output file %s : %s\n",
errfilename, strerror(errno));
free(outfilename);
free(errfilename);
+ free(expanded_arguments);
+ close(outfd);
return -1;
}
} else {
free(outfilename);
free(errfilename);
}
+ free(expanded_arguments);
return 0;
}
free(outfilename);
free(errfilename);
}
+ free(expanded_arguments);
return -1;
}
* at all.
*/
if (expanded_arguments != NULL) {
- if (asprintf(&exec_cmd, "%s %s", eo->program, expanded_arguments) < 0)
+ if (asprintf(&exec_cmd, "%s %s", eo->program, expanded_arguments) < 0) {
+ free(expanded_arguments);
return -1;
+ }
} else {
if (asprintf(&exec_cmd, "%s", eo->program) < 0)
return -1;
execvp(arguments_array[0], arguments_array);
}
/* We never reach this place */
+ /* Let's free the malloc'ed structures to make static checkers happy */
+ if (expanded_arguments)
+ free(expanded_arguments);
+ if (arguments_array)
+ free(arguments_array);
return 0;
}