Skip to content

Commit

Permalink
AURORA: Don't leak memory on LZMA exception throw
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed May 6, 2014
1 parent 68cd707 commit 6db9d82
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/aurora/bzffile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,19 @@ Common::SeekableReadStream *BZFFile::getResource(uint32 index) const {

byte *compressedData = new byte[res.packedSize];

if (bzf.read(compressedData, res.packedSize) != res.packedSize) {
Common::SeekableReadStream *resStream = 0;
try {
if (bzf.read(compressedData, res.packedSize) != res.packedSize)
throw Common::Exception(Common::kReadError);

resStream = decompress(compressedData, res.packedSize, res.size);

} catch (...) {
delete[] compressedData;
throw Common::Exception(Common::kReadError);
throw;
}

Common::SeekableReadStream *resStream = decompress(compressedData, res.packedSize, res.size);
delete[] compressedData;

return resStream;
}

Expand Down

0 comments on commit 6db9d82

Please sign in to comment.