]> git.tdb.fi Git - ext/subsurface.git/commitdiff
Fix array underrun when calculating velocity
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 21 Sep 2011 15:29:08 +0000 (08:29 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 21 Sep 2011 15:29:08 +0000 (08:29 -0700)
That code is messy. And it was buggy. Noticed by valgrind.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
profile.c

index f2cc526dd7ff4f15e33d2f85be1d080d6452cd8d..3f3dd42bc108f1c0b7e048a1521388e92e1a7c2d 100644 (file)
--- 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));