From 5d7de92eaff9ac2514e5992320c273c82d5d282d Mon Sep 17 00:00:00 2001 From: Denis Pronin Date: Thu, 10 Mar 2022 13:34:53 +0300 Subject: [PATCH] improvements in dup_files function cleared allocation of td->files when duplicating files, call 'assert', before iterating over original thread_data, that prevents possible segmentation fault when duplicating files Signed-off-by: Denis Pronin --- filesetup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/filesetup.c b/filesetup.c index 7c32d0af..ab6c488b 100644 --- a/filesetup.c +++ b/filesetup.c @@ -2031,11 +2031,12 @@ void dup_files(struct thread_data *td, struct thread_data *org) if (!org->files) return; - td->files = malloc(org->files_index * sizeof(f)); + td->files = calloc(org->files_index, sizeof(f)); if (td->o.file_lock_mode != FILE_LOCK_NONE) td->file_locks = malloc(org->files_index); + assert(org->files_index >= org->o.nr_files); for_each_file(org, f, i) { struct fio_file *__f; -- 2.25.1