From 3daf7a2d0f48c7fb1a098cfc47f7739f43b0509d Mon Sep 17 00:00:00 2001 From: Julian Kunkel Date: Tue, 19 Jan 2021 21:23:30 +0000 Subject: [PATCH] Bugfix: valgrind memory issues (#314) --- src/md-workbench.c | 4 +++- src/mdtest.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/md-workbench.c b/src/md-workbench.c index 869b4fd..7c130b1 100644 --- a/src/md-workbench.c +++ b/src/md-workbench.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "md-workbench.h" #include "config.h" @@ -343,7 +344,8 @@ static int compare_floats(time_result_t * x, time_result_t * y){ } static double runtime_quantile(int repeats, time_result_t * times, float quantile){ - int pos = round(quantile * repeats + 0.49); + int pos = round(quantile * (repeats - 1) + 0.49); + assert(pos < repeats); return times[pos].runtime; } diff --git a/src/mdtest.c b/src/mdtest.c index 5fe4263..6d610df 100644 --- a/src/mdtest.c +++ b/src/mdtest.c @@ -668,6 +668,7 @@ void mdtest_read(int random, int dirs, const long dir_iter, char *path) { if (alloc_res) { FAIL("out of memory"); } + memset(read_buffer, -1, o.read_bytes); } uint64_t stop_items = o.items;