aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-05-17 12:17:30 +0000
committerTorbjörn Andersson2005-05-17 12:17:30 +0000
commitbfbbf485859c18591c20ca6019ff8eb8ef62ad54 (patch)
treef429d0ac04a2eef6afa7d1f3bfd6fb5affddb165
parent8d782007c19c50240bf3101013ea57e8ca35bc76 (diff)
downloadscummvm-rg350-bfbbf485859c18591c20ca6019ff8eb8ef62ad54.tar.gz
scummvm-rg350-bfbbf485859c18591c20ca6019ff8eb8ef62ad54.tar.bz2
scummvm-rg350-bfbbf485859c18591c20ca6019ff8eb8ef62ad54.zip
Added clipping to drawLine(). This fixes a regression that caused the
debug console to crash ScummVM. (I'm not sure, but I think it was trying to draw the scrollbar arrows outside the screen when the console was sliding into view.) svn-id: r18138
-rw-r--r--graphics/surface.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index b0585eab15..2c0f2c4da1 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -27,14 +27,18 @@ namespace Graphics {
static void plotPoint1(int x, int y, int color, void *data) {
Surface *s = (Surface *)data;
- byte *ptr = (byte *)s->getBasePtr(x, y);
- *ptr = (byte)color;
+ if (x >= 0 && x < s->w && y >= 0 && y < s->h) {
+ byte *ptr = (byte *)s->getBasePtr(x, y);
+ *ptr = (byte)color;
+ }
}
static void plotPoint2(int x, int y, int color, void *data) {
Surface *s = (Surface *)data;
- uint16 *ptr = (uint16 *)s->getBasePtr(x, y);
- *ptr = (uint16)color;
+ if (x >= 0 && x < s->w && y >= 0 && y < s->h) {
+ uint16 *ptr = (uint16 *)s->getBasePtr(x, y);
+ *ptr = (uint16)color;
+ }
}
void Surface::drawLine(int x0, int y0, int x1, int y1, uint32 color) {