Don't stack allocate file name
[fio.git] / init.c
diff --git a/init.c b/init.c
index f3c756e960dc4c33afe8a3503236921311b1baf6..ea531591eed47b4e9c7ce2b67cad7f97c2cfef8d 100644 (file)
--- a/init.c
+++ b/init.c
@@ -752,7 +752,9 @@ static void fixup_options(struct thread_data *td)
        if (td->iodepth_batch > td->iodepth || !td->iodepth_batch)
                td->iodepth_batch = td->iodepth;
 
-       if (td->open_files > td->nr_files || !td->open_files)
+       if (!td->nr_files)
+               td->nr_files = td->open_files;
+       else if (td->open_files > td->nr_files || !td->open_files)
                td->open_files = td->nr_files;
 }
 
@@ -1101,12 +1103,16 @@ static int str_fst_cb(void *data, const char *str)
 static int str_filename_cb(void *data, const char *input)
 {
        struct thread_data *td = data;
-       char *fname, *str;
+       char *fname, *str, *p;
 
-       str = strdup(input);
-       while ((fname = strsep(&str, ":")) != NULL)
+       td->nr_files = 0;
+       p = str = strdup(input);
+       while ((fname = strsep(&str, ":")) != NULL) {
                add_file(td, fname);
+               td->nr_files++;
+       }
 
+       free(p);
        return 0;
 }