Don't stack allocate file name
authorJens Axboe <jens.axboe@oracle.com>
Tue, 13 Mar 2007 10:12:14 +0000 (11:12 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 13 Mar 2007 10:12:14 +0000 (11:12 +0100)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
filesetup.c
init.c

index f3fccdbed483f1849698fb917fd08db95784e3a5..c189de599f62066b72d8652ef2f4cdfc9c62d9f4 100644 (file)
@@ -438,7 +438,7 @@ void add_file(struct thread_data *td, const char *fname)
        f = &td->files[cur_files];
        memset(f, 0, sizeof(*f));
        f->fd = -1;
        f = &td->files[cur_files];
        memset(f, 0, sizeof(*f));
        f->fd = -1;
-       f->file_name = fname;
+       f->file_name = strdup(fname);
 
        get_file_type(td, f);
 
 
        get_file_type(td, f);
 
diff --git a/init.c b/init.c
index 66a50b03dbb8187b88db9fee3f6865a1fd0b26e7..ea531591eed47b4e9c7ce2b67cad7f97c2cfef8d 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1103,15 +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;
 static int str_filename_cb(void *data, const char *input)
 {
        struct thread_data *td = data;
-       char *fname, *str;
+       char *fname, *str, *p;
 
        td->nr_files = 0;
 
        td->nr_files = 0;
-       str = strdup(input);
+       p = str = strdup(input);
        while ((fname = strsep(&str, ":")) != NULL) {
                add_file(td, fname);
                td->nr_files++;
        }
 
        while ((fname = strsep(&str, ":")) != NULL) {
                add_file(td, fname);
                td->nr_files++;
        }
 
+       free(p);
        return 0;
 }
 
        return 0;
 }