aboutsummaryrefslogtreecommitdiff
path: root/engines/supernova/supernova.cpp
diff options
context:
space:
mode:
authorThierry Crozat2017-11-05 15:47:33 +0000
committerThierry Crozat2018-01-23 02:15:37 +0000
commit8f7dcbe4ac77da2d5c6a0d4658ee813a17369944 (patch)
tree599fad62764e7f85af6aa013aff00074931232e5 /engines/supernova/supernova.cpp
parent841e7182f28471ffda0ecd0c692649f58fd3aea8 (diff)
downloadscummvm-rg350-8f7dcbe4ac77da2d5c6a0d4658ee813a17369944.tar.gz
scummvm-rg350-8f7dcbe4ac77da2d5c6a0d4658ee813a17369944.tar.bz2
scummvm-rg350-8f7dcbe4ac77da2d5c6a0d4658ee813a17369944.zip
SUPERNOVA: Fix crash when displaying strings larger than the screen
Diffstat (limited to 'engines/supernova/supernova.cpp')
-rw-r--r--engines/supernova/supernova.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp
index 291e18d964..5bc87872c5 100644
--- a/engines/supernova/supernova.cpp
+++ b/engines/supernova/supernova.cpp
@@ -967,16 +967,32 @@ ScreenBufferStack::ScreenBufferStack()
: _last(_buffer) {
}
-void ScreenBufferStack::push(int x, int y, int width, int height, int pitch) {
+void ScreenBufferStack::push(int x, int y, int width, int height) {
if (_last == ARRAYEND(_buffer))
return;
+ Graphics::Surface* screenSurface = g_system->lockScreen();
+
+ if (x < 0) {
+ width += x;
+ x = 0;
+ }
+ if (x + width > screenSurface->w)
+ width = screenSurface->w - x;
+
+ if (y < 0) {
+ height += y;
+ y = 0;
+ }
+ if (y + height > screenSurface->h)
+ height = screenSurface->h - y;
+
_last->_pixels = new byte[width * height];
byte *pixels = _last->_pixels;
- const byte *screen = static_cast<const byte *>(g_system->lockScreen()->getBasePtr(x, y));
+ const byte *screen = static_cast<const byte *>(screenSurface->getBasePtr(x, y));
for (int i = 0; i < height; ++i) {
Common::copy(screen, screen + width, pixels);
- screen += pitch;
+ screen += screenSurface->pitch;
pixels += width;
}
g_system->unlockScreen();
@@ -985,7 +1001,6 @@ void ScreenBufferStack::push(int x, int y, int width, int height, int pitch) {
_last->_y = y;
_last->_width = width;
_last->_height = height;
- _last->_pitch = pitch;
++_last;
}