From d6bbf5d1ef0b489bd842ff64bbe6bc091f8c2abb Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 4 Oct 2012 19:30:14 +0200 Subject: [PATCH] paintRect should support negative x and y without this page, highlights which land outside of page in negative direction will core-dump reader --- blitbuffer.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/blitbuffer.c b/blitbuffer.c index b149923d8..6345025d7 100644 --- a/blitbuffer.c +++ b/blitbuffer.c @@ -332,9 +332,25 @@ static int paintRect(lua_State *L) { uint8_t *dstptr; int cy; - if(w <= 0 || h <= 0 || x >= dst->w || y >= dst->h) { - return 0; + + if(x < 0) { + if (x+w > 0) { + w += x; + x = 0; + } else { + return 0; + } } + + if(y < 0) { + if (y+h > 0) { + h += y; + y = 0; + } else { + return 0; + } + } + if(x + w > dst->w) { w = dst->w - x; } @@ -342,6 +358,10 @@ static int paintRect(lua_State *L) { h = dst->h - y; } + if(w <= 0 || h <= 0 || x >= dst->w || y >= dst->h) { + return 0; + } + if(x & 1) { /* This will render the leftmost column * in the case when x is odd. After this,