diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-05-07 16:47:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-05-07 16:48:53 +0300 |
commit | 6d402610c1c053f4febe3d1ed4da34c7af0bd276 (patch) | |
tree | 3160b6c8e202eee48f1c43a041f7e00d02d50d27 /source/blender/blenlib | |
parent | f5930759a68dc464181a971c67314be6ab712315 (diff) |
Correct error in wrapped array-span-iteration
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/array_utils.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/array_utils.c b/source/blender/blenlib/intern/array_utils.c index cbc9b49075f..5d485e2033d 100644 --- a/source/blender/blenlib/intern/array_utils.c +++ b/source/blender/blenlib/intern/array_utils.c @@ -196,6 +196,9 @@ bool _bli_array_iter_span( if (arr_len == 0) { return false; } + else if (use_wrap && (span_step[0] != arr_len) && (span_step[0] > span_step[1])) { + return false; + } const unsigned int arr_stride_uint = (unsigned int)arr_stride; const void *item_prev; @@ -252,7 +255,12 @@ bool _bli_array_iter_span( } } - span_len = (i_step_prev - ((i_step_prev >= i_curr) ? i_curr : (i_curr + arr_len))) + 1; + if (i_step_prev < i_curr) { + span_len = (i_step_prev + (arr_len - i_curr)) + 1; + } + else { + span_len = (i_step_prev - i_curr) + 1; + } } else { unsigned int i_step = i_curr + 1; |