diff options
author | Kari Salminen | 2008-08-11 20:09:03 +0000 |
---|---|---|
committer | Kari Salminen | 2008-08-11 20:09:03 +0000 |
commit | 02c9cb35f4e190891a4d59a2f335b817a9147334 (patch) | |
tree | 066ff88963a35fbfd50f6c29cadc2fc8e2355246 /engines/cine | |
parent | 3fdc69941108f98bde114b3528c56c720630cbdb (diff) | |
download | scummvm-rg350-02c9cb35f4e190891a4d59a2f335b817a9147334.tar.gz scummvm-rg350-02c9cb35f4e190891a4d59a2f335b817a9147334.tar.bz2 scummvm-rg350-02c9cb35f4e190891a4d59a2f335b817a9147334.zip |
Changed readBundleFile to unpack data in-place and added debugging messages to the function.
svn-id: r33781
Diffstat (limited to 'engines/cine')
-rw-r--r-- | engines/cine/part.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/engines/cine/part.cpp b/engines/cine/part.cpp index d605bdd623..d2fecfc554 100644 --- a/engines/cine/part.cpp +++ b/engines/cine/part.cpp @@ -221,17 +221,21 @@ void readFromPart(int16 idx, byte *dataPtr) { byte *readBundleFile(int16 foundFileIdx) { assert(foundFileIdx >= 0 && foundFileIdx < numElementInPart); + bool error = false; byte *dataPtr = (byte *)calloc(partBuffer[foundFileIdx].unpackedSize, 1); - if (partBuffer[foundFileIdx].unpackedSize != partBuffer[foundFileIdx].packedSize) { - byte *unpackBuffer = (byte *)malloc(partBuffer[foundFileIdx].packedSize); - readFromPart(foundFileIdx, unpackBuffer); + readFromPart(foundFileIdx, dataPtr); + if (partBuffer[foundFileIdx].unpackedSize > partBuffer[foundFileIdx].packedSize) { CineUnpacker cineUnpacker; - if (!cineUnpacker.unpack(unpackBuffer, partBuffer[foundFileIdx].packedSize, dataPtr, partBuffer[foundFileIdx].unpackedSize)) { - warning("Error unpacking '%s' from bundle file '%s'", partBuffer[foundFileIdx].partName, currentPartName); - } - free(unpackBuffer); - } else { - readFromPart(foundFileIdx, dataPtr); + error = !cineUnpacker.unpack(dataPtr, partBuffer[foundFileIdx].packedSize, dataPtr, partBuffer[foundFileIdx].unpackedSize); + } else if (partBuffer[foundFileIdx].unpackedSize < partBuffer[foundFileIdx].packedSize) { + // Unpacked size of a file should never be less than its packed size + error = true; + } else { // partBuffer[foundFileIdx].unpackedSize == partBuffer[foundFileIdx].packedSize + debugC(5, kCineDebugPart, "Loaded non-compressed file '%s' from bundle file '%s'", partBuffer[foundFileIdx].partName, currentPartName); + } + + if (error) { + warning("Error unpacking '%s' from bundle file '%s'", partBuffer[foundFileIdx].partName, currentPartName); } return dataPtr; |