diff options
author | Thomas White <taw@physics.org> | 2014-10-22 13:02:24 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2015-01-29 13:23:38 +0100 |
commit | 4942a69325c40ce8d055f02f66335648c9720334 (patch) | |
tree | 48de7249f8209de6733443d94b0714a454394533 /src | |
parent | 4c7ad11b03e00727b32ea6c1efd51d38cb868c83 (diff) |
Avoid reading past end of window
Diffstat (limited to 'src')
-rw-r--r-- | src/whirligig.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/whirligig.c b/src/whirligig.c index 4049c5eb..12896037 100644 --- a/src/whirligig.c +++ b/src/whirligig.c @@ -169,6 +169,8 @@ static void find_ser(struct window *win, int sn, int is_last_frame) int ser_start = 0; int in_series = 0; + assert(win->join_ptr <= win->ws); + for ( i=0; i<win->join_ptr; i++ ) { if ( in_series && win->ser[sn][i] == -1 ) { @@ -336,6 +338,8 @@ static IntegerMatrix *try_all(struct window *win, int n1, int n2, assert(n1 >= 0); assert(n2 >= 0); + assert(n1 < win->ws); + assert(n2 < win->ws); i1 = &win->img[n1]; i2 = &win->img[n2]; @@ -426,7 +430,7 @@ static int try_join(struct window *win, int sn) static void connect_series(struct window *win) { - do { + while ( win->join_ptr < win->ws ) { int i; int joined = 0; @@ -466,7 +470,7 @@ static void connect_series(struct window *win) win->join_ptr++; - } while ( win->join_ptr < win->ws ); + }; } |