aboutsummaryrefslogtreecommitdiff
path: root/engines/saga/saga.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/saga/saga.cpp')
-rw-r--r--engines/saga/saga.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp
index 1b7fa97f8d..13567f67b5 100644
--- a/engines/saga/saga.cpp
+++ b/engines/saga/saga.cpp
@@ -425,7 +425,11 @@ void SagaEngine::loadStrings(StringsTable &stringsTable, const byte *stringsPoin
prevOffset = offset;
if (offset == stringsLength) {
stringsCount = i;
- stringsTable.strings = (const char **)realloc(stringsTable.strings, stringsCount * sizeof(*stringsTable.strings));
+ const char **tmp = (const char **)realloc(stringsTable.strings, stringsCount * sizeof(*stringsTable.strings));
+ if (tmp)
+ stringsTable.strings = tmp;
+ else
+ error("SagaEngine::loadStrings() Error while reallocating memory");
break;
}
if (offset > stringsLength) {
@@ -433,7 +437,11 @@ void SagaEngine::loadStrings(StringsTable &stringsTable, const byte *stringsPoin
// translation of IHNM
warning("SagaEngine::loadStrings wrong strings table");
stringsCount = i;
- stringsTable.strings = (const char **)realloc(stringsTable.strings, stringsCount * sizeof(*stringsTable.strings));
+ const char **tmp = (const char **)realloc(stringsTable.strings, stringsCount * sizeof(*stringsTable.strings));
+ if (tmp)
+ stringsTable.strings = tmp;
+ else
+ error("SagaEngine::loadStrings() Error while reallocating memory");
break;
}
stringsTable.strings[i] = (const char *)stringsTable.stringsPointer + offset;