diff options
author | mano-wii <germano.costa@ig.com.br> | 2019-05-22 02:56:27 +0300 |
---|---|---|
committer | mano-wii <germano.costa@ig.com.br> | 2019-05-22 02:57:03 +0300 |
commit | fa542237dd0f7f7f64db42267de4b78df4cda94e (patch) | |
tree | 3d6be14c92eef67acc7376c941dd54ddf6ccd66b /source/blender/gpu/intern/gpu_select.c | |
parent | 73f7ed7ffadcae3795910155d52453650d4e97a4 (diff) |
GPU_select_buffer_stride_realign: fix crash when one of the rect's dimensions is 0.
Diffstat (limited to 'source/blender/gpu/intern/gpu_select.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_select.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c index 010087e5536..119aed2f5ed 100644 --- a/source/blender/gpu/intern/gpu_select.c +++ b/source/blender/gpu/intern/gpu_select.c @@ -229,12 +229,18 @@ void GPU_select_buffer_stride_realign(const rcti *src, const rcti *dst, uint *r_ const int dst_x = BLI_rcti_size_x(dst); const int dst_y = BLI_rcti_size_y(dst); - int last_px_written = dst_x * dst_y - 1; int last_px_id = src_x * (y + dst_y - 1) + (x + dst_x - 1); - const int skip = src_x - dst_x; - memset(&r_buf[last_px_id + 1], 0, (src_x * src_y - (last_px_id + 1)) * sizeof(*r_buf)); + if (last_px_id < 0) { + /* Nothing to write. */ + BLI_assert(last_px_id == -1); + return; + } + + int last_px_written = dst_x * dst_y - 1; + const int skip = src_x - dst_x; + while (true) { for (int i = dst_x; i--;) { r_buf[last_px_id--] = r_buf[last_px_written--]; |