diff options
author | sluicebox | 2019-11-25 16:18:53 -0800 |
---|---|---|
committer | sluicebox | 2019-11-25 16:41:15 -0800 |
commit | b658ef31deb46019359824da5deba62295ffa990 (patch) | |
tree | 461c891a031a6ff5dcb4ef00d40d89662134a0d2 /engines/sci/engine | |
parent | df41cb125fe5f66919030ebc60304df01356cded (diff) | |
download | scummvm-rg350-b658ef31deb46019359824da5deba62295ffa990.tar.gz scummvm-rg350-b658ef31deb46019359824da5deba62295ffa990.tar.bz2 scummvm-rg350-b658ef31deb46019359824da5deba62295ffa990.zip |
SCI32: Fix kFileIOReadRaw when fewer bytes than requested
Fixes censorship password in Phantasmagoria 1
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/kfile.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index f364e9d79f..007f8056a7 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -586,18 +586,15 @@ reg_t kFileIOReadRaw(EngineState *s, int argc, reg_t *argv) { uint16 handle = argv[0].toUint16(); uint16 size = argv[2].toUint16(); int bytesRead = 0; - char *buf = new char[size]; + byte *buf = new byte[size]; debugC(kDebugLevelFile, "kFileIO(readRaw): %d, %d", handle, size); FileHandle *f = getFileFromHandle(s, handle); if (f) bytesRead = f->_in->read(buf, size); - // TODO: What happens if less bytes are read than what has - // been requested? (i.e. if bytesRead is non-zero, but still - // less than size) if (bytesRead > 0) - s->_segMan->memcpy(argv[1], (const byte*)buf, size); + s->_segMan->memcpy(argv[1], buf, bytesRead); delete[] buf; return make_reg(0, bytesRead); |