diff options
author | athrxx | 2019-02-24 19:56:31 +0100 |
---|---|---|
committer | athrxx | 2019-03-06 20:48:24 +0100 |
commit | c3fa4c02ab11381b9139709882d85a14a19aa39a (patch) | |
tree | a419e46751d1f0a9947da93229649f5c8d9f0ea2 /engines/kyra/graphics/screen_eob.cpp | |
parent | 94ab4c83527d9f7bcec97bf959899dc655f8ba66 (diff) | |
download | scummvm-rg350-c3fa4c02ab11381b9139709882d85a14a19aa39a.tar.gz scummvm-rg350-c3fa4c02ab11381b9139709882d85a14a19aa39a.tar.bz2 scummvm-rg350-c3fa4c02ab11381b9139709882d85a14a19aa39a.zip |
KYRA: (EOB) - fix possible out of bounds mem access
(This can't happen through normal gameplay, but still better to be fixed)
Diffstat (limited to 'engines/kyra/graphics/screen_eob.cpp')
-rw-r--r-- | engines/kyra/graphics/screen_eob.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/engines/kyra/graphics/screen_eob.cpp b/engines/kyra/graphics/screen_eob.cpp index 90e2d1f41f..4cd471ee0a 100644 --- a/engines/kyra/graphics/screen_eob.cpp +++ b/engines/kyra/graphics/screen_eob.cpp @@ -1755,7 +1755,7 @@ bool OldDOSFont::load(Common::SeekableReadStream &file) { _width = _data[0x103]; _height = _data[0x102]; - _numGlyphs = 255; + _numGlyphs = (READ_LE_UINT16(_data + 2) / 2) - 2; _bitmapOffsets = (uint16 *)(_data + 2); @@ -1766,8 +1766,10 @@ bool OldDOSFont::load(Common::SeekableReadStream &file) { } int OldDOSFont::getCharWidth(uint16 c) const { - if (c >= _numGlyphs) - return 0; + // Since these fonts have a fixed character width we always give a return value + // even if there is no glyph for the specified character (which can't normally + // happen anyway - you'd have to do something like importing a Japanese save file + // into the English version). return _width; } @@ -1822,6 +1824,9 @@ void OldDOSFont::drawChar(uint16 c, byte *dst, int pitch, int bpp) const { } } + if (c >= _numGlyphs) + return; + pitch *= bpp; const uint8 *src = &_data[_bitmapOffsets[c]]; uint8 *dst2 = dst + pitch; |