CRYOMNI3D: Fix use after free when playing dialog

This commit is contained in:
Le Philousophe 2019-03-06 20:57:19 +01:00 committed by Eugene Sandulenko
parent 8d770af865
commit c7205da58b

View File

@ -257,6 +257,9 @@ bool DialogsManager::play(const Common::String &sequence, bool &slowStop) {
bool playerLabel = !strncmp(label, "JOU", 3);
bool didSomething = false;
bool finished = false;
/* Keep the gotoList outside the loop to avoid it being freed at the end of it and
* having label possibly pointing on free memory */
Common::Array<DialogsManager::Goto> gotoList;
while (!finished) {
const char *actions;
if (playerLabel) {
@ -284,7 +287,7 @@ bool DialogsManager::play(const Common::String &sequence, bool &slowStop) {
didSomething = true;
actions = nextLine(text);
}
Common::Array<DialogsManager::Goto> gotoList = executeAfterPlayAndBuildGotoList(actions);
gotoList = executeAfterPlayAndBuildGotoList(actions);
Common::StringArray questions;
bool endOfConversationFound = false;;
if (_ignoreNoEndOfConversation) {