From b658ef31deb46019359824da5deba62295ffa990 Mon Sep 17 00:00:00 2001 From: sluicebox Date: Mon, 25 Nov 2019 16:18:53 -0800 Subject: SCI32: Fix kFileIOReadRaw when fewer bytes than requested Fixes censorship password in Phantasmagoria 1 --- engines/sci/engine/kfile.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'engines') 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); -- cgit v1.2.3