Skip to contentSkip to conversation

fix an overflowing.

PATCH Applied majianpeng 2 participants 2 messages Jan 10, 2013

lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH 1/1 fix an overflowing.

Because nr_files and new_size are not same types.It can cause new_size less than zero.Then realloc will be failed.

---
 filesetup.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
filesetup.c +1 -1
index 324e9a6..c55ff3f 100644
@@ -1074,7 +1074,7 @@ int add_file(struct thread_data *td, const char *fname)
 	fio_file_reset(f);
 
 	if (td->files_size <= td->files_index) {
-		int new_size = td->o.nr_files + 1;
+		unsigned int new_size = td->o.nr_files + 1;
 
 		dprint(FD_FILE, "resize file array to %d files\n", new_size);
 		td->files = realloc(td->files, new_size * sizeof(f));
Signature · 1 line
1.7.9.5
Applied
#1 lore raw
Quoted 2 lines · majianpeng

Because nr_files and new_size are not same types.It can cause new_size less than zero.Then realloc will be failed.

Thanks, applied.

Signature · 1 line
Jens Axboe