diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-03-25 22:19:40 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-03-25 22:19:40 +0400 |
commit | 337be23cea3aac29a41c571fa345380c8a0fa404 (patch) | |
tree | e41ff11597c975d038bb38649d3badf070950d03 /source/blender/bmesh | |
parent | d3c596035bdf2312891bad7a86b4b047c91d96e6 (diff) |
Fix bug #30673, "Crash: Bridge a pair of edges."
Fix edge case for clamp_index() with any negative 'x' that is a
multiple of 'len', was returning 'len' which is invalid index.
Maybe the expression can be simplified back to a one-liner?
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/operators/bmo_connect.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c index e135473fc7e..20af3463891 100644 --- a/source/blender/bmesh/operators/bmo_connect.c +++ b/source/blender/bmesh/operators/bmo_connect.c @@ -141,7 +141,15 @@ static BMVert *get_outer_vert(BMesh *bm, BMEdge *e) /* Clamp x to the interval {0..len-1}, with wrap-around */ static int clamp_index(const int x, const int len) { - return (x < 0) ? (len - (-x % len)) : (x % len); + if (x >= 0) + return x % len; + else { + int r = len - (-x % len); + if(r == len) + return len - 1; + else + return r; + } } /* There probably is a better way to swap BLI_arrays, or if there |