summaryrefslogtreecommitdiff
path: root/src/graphics/RasterDrawMethods.inl
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-07-27 19:53:09 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-07-27 19:53:09 (GMT)
commitb612c076ebf255655160274e9665faa16c6c5b9e (patch)
treed931de2a4ee7159f05695fddc60f8392b629cd29 /src/graphics/RasterDrawMethods.inl
parent5befe5c25f8f188e7588de44ab2c8bead22ae999 (diff)
downloadpowder-b612c076ebf255655160274e9665faa16c6c5b9e.zip
powder-b612c076ebf255655160274e9665faa16c6c5b9e.tar.gz
Prevent crash when drawing an image out of mounts on a pixel grid
Diffstat (limited to 'src/graphics/RasterDrawMethods.inl')
-rw-r--r--src/graphics/RasterDrawMethods.inl5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/graphics/RasterDrawMethods.inl b/src/graphics/RasterDrawMethods.inl
index cce81d2..b5d52a9 100644
--- a/src/graphics/RasterDrawMethods.inl
+++ b/src/graphics/RasterDrawMethods.inl
@@ -329,8 +329,9 @@ void PIXELMETHODS_CLASS::clearrect(int x, int y, int w, int h)
void PIXELMETHODS_CLASS::draw_image(pixel *img, int x, int y, int w, int h, int a)
{
int i, j, r, g, b;
- if (!img || y >= VIDYRES) return;
- if(y + h > VIDYRES) h = (VIDYRES)-y; //Adjust height to prevent drawing off the bottom
+ if (!img) return;
+ if(y + h > VIDYRES) h = ((VIDYRES)-y)-1; //Adjust height to prevent drawing off the bottom
+ if(!h || y < 0) return;
if(a >= 255)
for (j=0; j<h; j++)
for (i=0; i<w; i++)