mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-16 06:39:17 +00:00
SCI32: Fix kFileIOReadRaw when fewer bytes than requested
Fixes censorship password in Phantasmagoria 1
This commit is contained in:
parent
df41cb125f
commit
b658ef31de
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user