paintRect should support negative x and y

without this page, highlights which land outside of page in negative
direction will core-dump reader
This commit is contained in:
Dobrica Pavlinusic
2012-10-04 19:30:14 +02:00
parent 1ced4ceb17
commit d6bbf5d1ef

View File

@@ -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,