From cceae8ad0a87064fa06b8a1855dcd6c65195453f Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Fri, 5 Oct 2012 14:33:24 +0200 Subject: [PATCH] add negative x,y checking in dimRect --- blitbuffer.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/blitbuffer.c b/blitbuffer.c index 6345025d7..90e2e55d5 100644 --- a/blitbuffer.c +++ b/blitbuffer.c @@ -489,6 +489,27 @@ static int dimRect(lua_State *L) { uint8_t *dstptr; int cy, cx; + + 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; }