From 4da24b69599f7f78dc1420345f91d90ec0cfe109 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 15 Apr 2015 21:47:47 -0600 Subject: [PATCH] Fix wrong index bug Commit 0e4dd95c548cc re-uses 'i' as an iterator, causing us to overrun the nr_ts allocated. This subsequently causes fio to segfault. Fixes: 0e4dd95c548cc Signed-off-by: Jens Axboe --- stat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stat.c b/stat.c index 34e3792f..e42edc91 100644 --- a/stat.c +++ b/stat.c @@ -1369,7 +1369,7 @@ void __show_run_stats(void) struct group_run_stats *runstats, *rs; struct thread_data *td; struct thread_stat *threadstats, *ts; - int i, j, nr_ts, last_ts, idx; + int i, j, k, nr_ts, last_ts, idx; int kb_base_warned = 0; int unit_base_warned = 0; struct json_object *root = NULL; @@ -1481,8 +1481,8 @@ void __show_run_stats(void) ts->latency_window = td->o.latency_window; ts->nr_block_infos = td->ts.nr_block_infos; - for (i = 0; i < ts->nr_block_infos; i++) - ts->block_infos[i] = td->ts.block_infos[i]; + for (k = 0; k < ts->nr_block_infos; k++) + ts->block_infos[k] = td->ts.block_infos[k]; sum_thread_stats(ts, &td->ts, idx); } -- 2.25.1