Don't leak f_out file desciptor if specified more than once
[fio.git] / init.c
diff --git a/init.c b/init.c
index 1c37ab92f5209af2830e3b9920f8ffa64b47fc80..35fbdf15365b3661b4dea465b2ae978be096cb59 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1719,6 +1719,9 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                        write_bw_log = 1;
                        break;
                case 'o':
+                       if (f_out)
+                               fclose(f_out);
+
                        f_out = fopen(optarg, "w+");
                        if (!f_out) {
                                perror("fopen output");
@@ -1828,6 +1831,8 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                        break;
                        }
                case 'p':
+                       if (exec_profile)
+                               free(exec_profile);
                        exec_profile = strdup(optarg);
                        break;
                case FIO_GETOPT_JOB: {