Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions tools/fftw-wisdom.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,21 @@ int bench_main(int argc, char *argv[])
break;

case 'o':
if (output_fname)
if (output_fname){
bench_free(output_fname);

output_fname = NULL;
}
if (!strcmp(my_optarg, "-"))
output_fname = 0;
else {
output_fname = (char *) bench_malloc(sizeof(char) *
(strlen(my_optarg) + 1));

/* Check for allocation failure to prevent NULL pointer dereference */
if (!output_fname) {
fprintf(stderr, "fftw-wisdom: out of memory\n");
exit(EXIT_FAILURE);
}
strcpy(output_fname, my_optarg);
}
break;
Expand Down