From f1db69d422ed93324633808763e8dbe8f09e5380 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 Nov 2016 16:07:16 -0500 Subject: TITANIC: Fix crash in setConcept when src is null --- engines/titanic/true_talk/tt_concept_node.cpp | 52 ++++++++++++++------------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'engines/titanic/true_talk') diff --git a/engines/titanic/true_talk/tt_concept_node.cpp b/engines/titanic/true_talk/tt_concept_node.cpp index f6512b3d81..ccba1b81bb 100644 --- a/engines/titanic/true_talk/tt_concept_node.cpp +++ b/engines/titanic/true_talk/tt_concept_node.cpp @@ -86,32 +86,34 @@ TTconcept **TTconceptNode::setConcept(int conceptIndex, TTconcept *src) { break; } - bool isPronoun = false; - StringArray &pronouns = g_vm->_scriptHandler->_parser._pronouns; - for (uint idx = 0; idx < pronouns.size() && !isPronoun; ++idx) { - isPronoun = pronouns[idx] == src->getText(); - } + if (src) { + bool isPronoun = false; + StringArray &pronouns = g_vm->_scriptHandler->_parser._pronouns; + for (uint idx = 0; idx < pronouns.size() && !isPronoun; ++idx) { + isPronoun = pronouns[idx] == src->getText(); + } - CScriptHandler &scrHandler = *g_vm->_exeResources._owner; - if (!isPronoun) { - switch (conceptIndex) { - case 0: - delete scrHandler._concept2P; - scrHandler._concept2P = new TTconcept(*src); - break; - - case 1: - delete scrHandler._concept4P; - scrHandler._concept4P = new TTconcept(*src); - break; - - case 2: - delete scrHandler._concept1P; - scrHandler._concept1P = new TTconcept(*src); - break; - - default: - break; + CScriptHandler &scrHandler = *g_vm->_exeResources._owner; + if (!isPronoun) { + switch (conceptIndex) { + case 0: + delete scrHandler._concept2P; + scrHandler._concept2P = new TTconcept(*src); + break; + + case 1: + delete scrHandler._concept4P; + scrHandler._concept4P = new TTconcept(*src); + break; + + case 2: + delete scrHandler._concept1P; + scrHandler._concept1P = new TTconcept(*src); + break; + + default: + break; + } } } -- cgit v1.2.3