Skip to content

Commit

Permalink
GUI: Fix memory leak. CID 1003569
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Apr 23, 2013
1 parent cfbc8be commit 92780a3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gui/predictivedialog.cpp
Expand Up @@ -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) {
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit 92780a3

Please sign in to comment.