Skip to content

Commit

Permalink
improvements in dup_files function
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dpronin committed Mar 10, 2022
1 parent df0ab55 commit 5d7de92
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion filesetup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 5d7de92

Please sign in to comment.