aboutsummaryrefslogtreecommitdiff
path: root/gui/predictivedialog.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2013-04-24 01:16:31 +0300
committerEugene Sandulenko2013-04-24 01:16:31 +0300
commit92780a33203e63dd2572c7fa4dcfe37d36b0966d (patch)
tree3c6936bba65be39f74c91c861cfe3a20b754f3f7 /gui/predictivedialog.cpp
parentcfbc8be75735370a4e87525a9b69b4556e24b9a9 (diff)
downloadscummvm-rg350-92780a33203e63dd2572c7fa4dcfe37d36b0966d.tar.gz
scummvm-rg350-92780a33203e63dd2572c7fa4dcfe37d36b0966d.tar.bz2
scummvm-rg350-92780a33203e63dd2572c7fa4dcfe37d36b0966d.zip
GUI: Fix memory leak. CID 1003569
Diffstat (limited to 'gui/predictivedialog.cpp')
-rw-r--r--gui/predictivedialog.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/gui/predictivedialog.cpp b/gui/predictivedialog.cpp
index ed18847a40..5ce093e054 100644
--- a/gui/predictivedialog.cpp
+++ b/gui/predictivedialog.cpp
@@ -779,7 +779,7 @@ bool PredictiveDialog::searchWord(const char *const where, const Common::String
}
void PredictiveDialog::addWord(Dict &dict, const Common::String &word, const Common::String &code) {
- char *newLine;
+ char *newLine = 0;
Common::String tmpCode = code + ' ';
int line = binarySearch(dict.dictLine, tmpCode, dict.dictLineCount);
if (line >= 0) {
@@ -856,6 +856,9 @@ void PredictiveDialog::addWord(Dict &dict, const Common::String &word, const Com
char **newDictLine = (char **)calloc(1, sizeof(char *) * (dict.dictLineCount + 1));
if (!newDictLine) {
warning("Predictive Dialog: cannot allocate memory for index buffer");
+
+ free(newLine);
+
return;
}
newDictLine[dict.dictLineCount] = '\0';