From fcc7a01c6e7f7973a1547b8794351311720cef43 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 21 Sep 2011 08:29:08 -0700 Subject: [PATCH] Fix array underrun when calculating velocity That code is messy. And it was buggy. Noticed by valgrind. Signed-off-by: Linus Torvalds --- profile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profile.c b/profile.c index f2cc526..3f3dd42 100644 --- a/profile.c +++ b/profile.c @@ -620,7 +620,7 @@ static struct plot_info *analyze_plot_info(struct plot_info *pi) /* if our samples are short and we aren't too FAST*/ if (entry[0].sec - entry[-1].sec < 30 && entry->velocity < FAST) { int past = -2; - while (pi->entry <= entry-past && entry[0].sec - entry[past].sec < 30) + while (i+past > 0 && entry[0].sec - entry[past].sec < 30) past--; entry->velocity = velocity((entry[0].val - entry[past].val) / (entry[0].sec - entry[past].sec)); -- 2.43.0