From 0760c929082f8a7d4fd99cf90d095d7b0ee4685b Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 27 Jan 2011 14:07:45 +0000 Subject: DRASCULA: Fix Memory Leak in drascula.dat Loading. svn-id: r55566 --- engines/drascula/drascula.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index cf0453b87c..258619fe40 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -1041,25 +1041,22 @@ char **DrasculaEngine::loadTexts(Common::File &in) { for (int lang = 0; lang < _numLangs; lang++) { entryLen = in.readUint16BE(); - pos = (char *)malloc(entryLen); if (lang == _lang) { - res[0] = pos; - in.read(res[0], entryLen); - } else { + pos = (char *)malloc(entryLen); in.read(pos, entryLen); - } - - pos += DATAALIGNMENT; + res[0] = pos; + pos += DATAALIGNMENT; - for (int i = 1; i < numTexts; i++) { - pos -= 2; + for (int i = 1; i < numTexts; i++) { + pos -= 2; - len = READ_BE_UINT16(pos); - pos += 2 + len; + len = READ_BE_UINT16(pos); + pos += 2 + len; - if (lang == _lang) res[i] = pos; - } + } + } else + in.seek(entryLen, SEEK_CUR); } return res; -- cgit v1.2.3