diff options
author | Andrew Kurushin | 2010-10-19 15:31:07 +0000 |
---|---|---|
committer | Andrew Kurushin | 2010-10-19 15:31:07 +0000 |
commit | 0e7abce271c218faa6ae19059207fed5d61b0ef8 (patch) | |
tree | e2df8762901d0d45dba9f6d1a6c88c817b44228f /engines/saga/saga.cpp | |
parent | f8c72439383c6ea6324d03fa4c9e067a33af2235 (diff) | |
download | scummvm-rg350-0e7abce271c218faa6ae19059207fed5d61b0ef8.tar.gz scummvm-rg350-0e7abce271c218faa6ae19059207fed5d61b0ef8.tar.bz2 scummvm-rg350-0e7abce271c218faa6ae19059207fed5d61b0ef8.zip |
SAGA: fix submit 53486 "Added sanity checks for realloc() calls - bug report #3087852". zero count realloc may return NULL as valid value
svn-id: r53614
Diffstat (limited to 'engines/saga/saga.cpp')
-rw-r--r-- | engines/saga/saga.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index 13567f67b5..1643ecfa17 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -426,10 +426,11 @@ void SagaEngine::loadStrings(StringsTable &stringsTable, const byte *stringsPoin if (offset == stringsLength) { stringsCount = i; const char **tmp = (const char **)realloc(stringsTable.strings, stringsCount * sizeof(*stringsTable.strings)); - if (tmp) + if ((tmp != NULL) || (stringsCount == 0)) { stringsTable.strings = tmp; - else + } else { error("SagaEngine::loadStrings() Error while reallocating memory"); + } break; } if (offset > stringsLength) { @@ -438,10 +439,11 @@ void SagaEngine::loadStrings(StringsTable &stringsTable, const byte *stringsPoin warning("SagaEngine::loadStrings wrong strings table"); stringsCount = i; const char **tmp = (const char **)realloc(stringsTable.strings, stringsCount * sizeof(*stringsTable.strings)); - if (tmp) + if ((tmp != NULL) || (stringsCount == 0)) { stringsTable.strings = tmp; - else + } else { error("SagaEngine::loadStrings() Error while reallocating memory"); + } break; } stringsTable.strings[i] = (const char *)stringsTable.stringsPointer + offset; |