aboutsummaryrefslogtreecommitdiff
path: root/engines/mads/conversations.cpp
diff options
context:
space:
mode:
authorStrangerke2015-11-24 23:58:54 +0100
committerStrangerke2015-11-24 23:58:54 +0100
commit1b9f1eed88612e1d217e3b6ec60fa8fb6e116117 (patch)
tree0b9ee7827ae098f45600588ecdb8bd7de6f2df62 /engines/mads/conversations.cpp
parentf5c0e1679245d59b62d4819004f81039838ba78b (diff)
downloadscummvm-rg350-1b9f1eed88612e1d217e3b6ec60fa8fb6e116117.tar.gz
scummvm-rg350-1b9f1eed88612e1d217e3b6ec60fa8fb6e116117.tar.bz2
scummvm-rg350-1b9f1eed88612e1d217e3b6ec60fa8fb6e116117.zip
MADS: Fix several memory leaks in the conversation code
Diffstat (limited to 'engines/mads/conversations.cpp')
-rw-r--r--engines/mads/conversations.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/engines/mads/conversations.cpp b/engines/mads/conversations.cpp
index 5328b21ff1..53b8e7900d 100644
--- a/engines/mads/conversations.cpp
+++ b/engines/mads/conversations.cpp
@@ -130,12 +130,16 @@ void GameConversation::get(int id) {
uint16 commandLength = convFile->readUint16LE(); // Total length of commands in section 6
//debug("Node entry commands length: %d", commandLength);
- /*debug("Section 0 unknown bytes");
+#if 0
+ debug("Section 0 unknown bytes");
byte *tmp0 = new byte[26];
convFile->read(tmp0, 26);
Common::hexdump(tmp0, 26);
- delete[] tmp0;*/
-
+ delete[] tmp0;
+ delete convFile;
+#else
+ warning("Section 0 unknown bytes");
+#endif
// **** Section 1: Nodes **************************************************
convFile = convFileUnpacked.getItemStream(1);
@@ -149,6 +153,7 @@ void GameConversation::get(int id) {
conv.convNodes.push_back(node);
//debug("Node %d, index %d, entries %d - %d, %d, %d", i, node.index, node.dialogCount, node.unk1, node.unk2, node.unk3);
}
+ delete convFile;
// **** Section 2: Dialogs ************************************************
convFile = convFileUnpacked.getItemStream(2);
@@ -167,16 +172,20 @@ void GameConversation::get(int id) {
//debug("Node %d, dialog %d: text line %d, speech index %d, node offset %d, node size %d", j, i, dialog.textLineIndex, dialog.speechIndex, dialog.nodeOffset, dialog.nodeSize);
}
}
+ delete convFile;
// **** Section 3: ???? ***************************************************
- /*debug("Section 3");
+#if 0
+ debug("Section 3");
convFile = convFileUnpacked.getItemStream(3);
byte *tmp1 = new byte[convFile->size()];
convFile->read(tmp1, convFile->size());
Common::hexdump(tmp1, convFile->size());
- delete[] tmp1;*/
- // TODO
-
+ delete[] tmp1;
+ delete convFile;
+#else
+ warning("Section 3 - TODO");
+#endif
// **** Section 4: Text line offsets **************************************
convFile = convFileUnpacked.getItemStream(4);
assert(convFile->size() == conv.textLineCount * 2);
@@ -185,6 +194,8 @@ void GameConversation::get(int id) {
for (uint16 i = 0; i < conv.textLineCount; i++)
textLineOffsets[i] = convFile->readUint16LE();
+ delete convFile;
+
// **** Section 5: Text lines *********************************************
convFile = convFileUnpacked.getItemStream(5);
assert(convFile->size() == textLength);
@@ -201,6 +212,7 @@ void GameConversation::get(int id) {
}
delete[] textLineOffsets;
+ delete convFile;
// **** Section 6: Node entry commands ************************************
convFile = convFileUnpacked.getItemStream(6);
@@ -272,6 +284,7 @@ void GameConversation::get(int id) {
}
}
+ delete convFile;
inFile.close();
/*