fix: memory leak instroduced in #110

This commit is contained in:
Evgeniy A. Dushistov
2025-08-17 13:43:07 +03:00
committed by Evgeniy Dushistov
parent d5e1eb4d93
commit 849f0ed1ac

View File

@@ -1047,10 +1047,11 @@ bool Libs::LookupSimilarWord(const gchar *sWord, std::set<glong> &iWordIndices,
} }
// Upper the first character and lower others. // Upper the first character and lower others.
if (!bFound) { if (!bFound) {
const gchar *nextchar = g_utf8_next_char(sWord); const gchar *rest = g_utf8_next_char(sWord);
gchar *firstchar = g_utf8_strup(sWord, nextchar - sWord); gchar *firstchar = g_utf8_strup(sWord, rest - sWord);
nextchar = g_utf8_strdown(nextchar, -1); gchar *rest_lowercase = g_utf8_strdown(rest, -1);
casestr = g_strdup_printf("%s%s", firstchar, nextchar); casestr = g_strdup_printf("%s%s", firstchar, rest_lowercase);
g_free(rest_lowercase);
g_free(firstchar); g_free(firstchar);
if (strcmp(casestr, sWord)) { if (strcmp(casestr, sWord)) {
if (oLib[iLib]->Lookup(casestr, iWordIndices)) if (oLib[iLib]->Lookup(casestr, iWordIndices))