mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-16 06:39:17 +00:00
CGE: Fix SPR files with extra 0x1A or missing ending CRLF. Fix bug #3537527
This commit is contained in:
parent
7b44c20eb1
commit
80388527ea
@ -201,9 +201,28 @@ EncryptedStream::EncryptedStream(CGEEngine *vm, const char *name) : _vm(vm) {
|
||||
_error = true;
|
||||
|
||||
_vm->_resman->seek(kp->_pos);
|
||||
byte *dataBuffer = (byte *)malloc(kp->_size);
|
||||
_vm->_resman->read(dataBuffer, kp->_size);
|
||||
_readStream = new Common::MemoryReadStream(dataBuffer, kp->_size, DisposeAfterUse::YES);
|
||||
byte *dataBuffer;
|
||||
int bufSize;
|
||||
|
||||
if ((strlen(name) > 4) && (scumm_stricmp(name + strlen(name) - 4, ".SPR") == 0)) {
|
||||
// SPR files have some inconsistencies. Some have extra 0x1A at the end, some others
|
||||
// do not have a carriage return at the end of the last line
|
||||
// Therefore, we remove this ending 0x1A and add extra new lines.
|
||||
// This fixes bug #3537527
|
||||
dataBuffer = (byte *)malloc(kp->_size + 2);
|
||||
_vm->_resman->read(dataBuffer, kp->_size);
|
||||
if (dataBuffer[kp->_size - 1] == 0x1A)
|
||||
dataBuffer[kp->_size - 1] = '\n';
|
||||
dataBuffer[kp->_size] = '\n';
|
||||
dataBuffer[kp->_size + 1] = '\n';
|
||||
bufSize = kp->_size + 2;
|
||||
} else {
|
||||
dataBuffer = (byte *)malloc(kp->_size);
|
||||
_vm->_resman->read(dataBuffer, kp->_size);
|
||||
bufSize = kp->_size;
|
||||
}
|
||||
|
||||
_readStream = new Common::MemoryReadStream(dataBuffer, bufSize, DisposeAfterUse::YES);
|
||||
}
|
||||
|
||||
uint32 EncryptedStream::read(void *dataPtr, uint32 dataSize) {
|
||||
|
Loading…
Reference in New Issue
Block a user