From 337be23cea3aac29a41c571fa345380c8a0fa404 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 25 Mar 2012 18:19:40 +0000 Subject: 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? --- source/blender/bmesh/operators/bmo_connect.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source/blender/bmesh/operators/bmo_connect.c') 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 -- cgit v1.2.3