From 27a5783afcd3fa968fc46bed5bcd119102191f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 4 Feb 2014 00:05:54 +0100 Subject: [PATCH] agg_clipped_alpha_mask.h: Partially revert previous commit. There wasn't an out-of-bounds access, I read the code wrongly. Keep the code in sync with the AGG version. What happens is that for x < 0 and xmax < 0, the code will memset the x < 0 region twice, unless I am still irritated... --- src/servers/app/agg_clipped_alpha_mask.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/servers/app/agg_clipped_alpha_mask.h b/src/servers/app/agg_clipped_alpha_mask.h index 73816ad1d7..59c77740e9 100644 --- a/src/servers/app/agg_clipped_alpha_mask.h +++ b/src/servers/app/agg_clipped_alpha_mask.h @@ -72,27 +72,27 @@ namespace agg x = 0; } - int rest = 0; if(x + count > xmax) { - rest = x + count - xmax - 1; + int rest = x + count - xmax - 1; count -= rest; + if(count <= 0) + { + memset(dst, m_outside, num_pix * sizeof(cover_type)); + return; + } + memset(covers + count, m_outside, rest * sizeof(cover_type)); } - + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; - while(count != 0) + do { *covers = (cover_type)((cover_full + (*covers) * (*mask)) - >> cover_shift); + >> cover_shift); ++covers; mask += Step; - --count; - } - - if(rest > 0) - { - memset(covers, m_outside, rest * sizeof(cover_type)); } + while(--count); } private: