From: Jianpeng Ma Date: Fri, 11 Jan 2013 07:52:55 +0000 (+0100) Subject: Add a check avoid segfault X-Git-Tag: fio-2.0.14~130 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=d537c08b0eacdeb05835ee8c5f269b872239713a Add a check avoid segfault If new_size was zero or realloc failed, it would be segment fault. So add a check. Signed-off-by: Jianpeng Ma Signed-off-by: Jens Axboe --- diff --git a/filesetup.c b/filesetup.c index 69eb37cd..ab5cc48d 100644 --- a/filesetup.c +++ b/filesetup.c @@ -1079,6 +1079,10 @@ int add_file(struct thread_data *td, const char *fname) dprint(FD_FILE, "resize file array to %d files\n", new_size); td->files = realloc(td->files, new_size * sizeof(f)); + if (td->files == NULL) { + log_err("fio: realloc OOM\n"); + assert(0); + } td->files_size = new_size; } td->files[cur_files] = f;