diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-09-21 08:29:08 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-09-21 08:29:08 -0700 |
commit | fcc7a01c6e7f7973a1547b8794351311720cef43 (patch) | |
tree | 5f171607a88f3b3ac81b3933e827692ba08e7961 /profile.c | |
parent | 74988c86de775f0fc8e5f0e366130bcdab5d33ac (diff) | |
download | subsurface-fcc7a01c6e7f7973a1547b8794351311720cef43.tar.gz |
Fix array underrun when calculating velocity
That code is messy. And it was buggy. Noticed by valgrind.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'profile.c')
-rw-r--r-- | profile.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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)); |