From 66efe66f61b76e4eee0cedebb04b1aef3d65e404 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Wed, 26 Sep 2012 18:54:49 +0200 Subject: [PATCH] invertRect should handle negative x or y values two-column mode combined with showing links in pdf files triggers this bug --- blitbuffer.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/blitbuffer.c b/blitbuffer.c index aef8bab72..0e4d30b69 100644 --- a/blitbuffer.c +++ b/blitbuffer.c @@ -394,6 +394,29 @@ static int invertRect(lua_State *L) { uint8_t *dstptr; int cy, cx; + + //printf("## invertRect x=%d y=%d w=%d h=%d\n",x,y,w,h); + + if (x < 0) { + if ( x + w > 0 ) { + w = w + x; + x = 0; + } else { + //printf("## invertRect x out of bound\n"); + return 0; + } + } + + if (y < 0) { + if ( y + h > 0 ) { + h = h + y; + y = 0; + } else { + //printf("## invertRect y out of bound\n"); + return 0; + } + } + if(w <= 0 || h <= 0 || x >= dst->w || y >= dst->h) { return 0; }