aboutsummaryrefslogtreecommitdiff
path: root/engines/saga/shorten.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/saga/shorten.cpp')
-rw-r--r--engines/saga/shorten.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/engines/saga/shorten.cpp b/engines/saga/shorten.cpp
index 2137423a5a..684b3a86bb 100644
--- a/engines/saga/shorten.cpp
+++ b/engines/saga/shorten.cpp
@@ -366,7 +366,11 @@ byte *loadShortenFromStream(Common::ReadStream &stream, int &size, int &rate, by
if (maxLPC < lpcNum) {
warning("Safeguard: maxLPC < lpcNum (should never happen)");
maxLPC = lpcNum;
- lpc = (int32 *) realloc(lpc, maxLPC * 4);
+ int32 *tmp = (int32 *) realloc(lpc, maxLPC * 4);
+ if (tmp)
+ lpc = tmp;
+ else
+ error("loadShortenFromStream(): Error while reallocating memory");
}
for (i = 0; i < lpcNum; i++)
@@ -430,7 +434,11 @@ byte *loadShortenFromStream(Common::ReadStream &stream, int &size, int &rate, by
prevSize = size;
size += (blockSize * dataSize);
- unpackedBuffer = (byte *) realloc(unpackedBuffer, size);
+ byte *tmp = (byte *) realloc(unpackedBuffer, size);
+ if (tmp)
+ unpackedBuffer = tmp;
+ else
+ error("loadShortenFromStream(): Error while reallocating memory");
pBuf = unpackedBuffer + prevSize;
if (flags & Audio::FLAG_16BITS) {
@@ -464,7 +472,11 @@ byte *loadShortenFromStream(Common::ReadStream &stream, int &size, int &rate, by
uint32 vLen = (uint32)gReader->getURice(5);
prevSize = size;
size += vLen;
- unpackedBuffer = (byte *) realloc(unpackedBuffer, size);
+ byte *tmp = (byte *) realloc(unpackedBuffer, size);
+ if (tmp)
+ unpackedBuffer = tmp;
+ else
+ error("loadShortenFromStream(): Error while reallocating memory");
pBuf = unpackedBuffer + prevSize;
while (vLen--) {