From: Jens Axboe Date: Tue, 13 Mar 2007 10:12:14 +0000 (+0100) Subject: Don't stack allocate file name X-Git-Tag: fio-1.14~24 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=cae61953cd7ee0dfc0d8b736553979f10ede7cd9;hp=0ad920e7f85db1fdc26649be6bc7e584e8c7fdc9;ds=sidebyside Don't stack allocate file name Signed-off-by: Jens Axboe --- diff --git a/filesetup.c b/filesetup.c index f3fccdbe..c189de59 100644 --- a/filesetup.c +++ b/filesetup.c @@ -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->file_name = fname; + f->file_name = strdup(fname); get_file_type(td, f); diff --git a/init.c b/init.c index 66a50b03..ea531591 100644 --- 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; - char *fname, *str; + char *fname, *str, *p; td->nr_files = 0; - str = strdup(input); + p = str = strdup(input); while ((fname = strsep(&str, ":")) != NULL) { add_file(td, fname); td->nr_files++; } + free(p); return 0; }