summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-04-12 10:42:44 +0800
committerPeng Wu <alexepico@gmail.com>2016-04-12 10:45:15 +0800
commit429cc899b778a472f52f8b59ee1f439729246b65 (patch)
tree207958cf5d5cf47cfbc203fb283289e8e98e296e /src
parent5c0158fed5d62a1c995c36486328c577d1b1d194 (diff)
downloadibus-libpinyin-429cc899b778a472f52f8b59ee1f439729246b65.tar.gz
ibus-libpinyin-429cc899b778a472f52f8b59ee1f439729246b65.tar.xz
ibus-libpinyin-429cc899b778a472f52f8b59ee1f439729246b65.zip
fixes leak
Diffstat (limited to 'src')
-rw-r--r--src/PYLibPinyin.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/PYLibPinyin.cc b/src/PYLibPinyin.cc
index 5e4f3b1..9905440 100644
--- a/src/PYLibPinyin.cc
+++ b/src/PYLibPinyin.cc
@@ -213,8 +213,10 @@ LibPinyinBackEnd::importPinyinDictionary (const char * filename)
import_iterator_t * iter = pinyin_begin_add_phrases
(m_pinyin_context, USER_DICTIONARY);
- if (NULL == iter)
+ if (NULL == iter) {
+ fclose(dictfile);
return FALSE;
+ }
char* linebuf = NULL; size_t size = 0; ssize_t read;
while ((read = getline (&linebuf, &size, dictfile)) != -1) {
@@ -261,8 +263,10 @@ LibPinyinBackEnd::exportPinyinDictionary (const char * filename)
export_iterator_t * iter = pinyin_begin_get_phrases
(m_pinyin_context, USER_DICTIONARY);
- if (NULL == iter)
+ if (NULL == iter) {
+ fclose(dictfile);
return FALSE;
+ }
/* use " " as the separator. */
while (pinyin_iterator_has_next_phrase (iter)) {
@@ -279,6 +283,7 @@ LibPinyinBackEnd::exportPinyinDictionary (const char * filename)
g_free (phrase); g_free (pinyin);
}
+ pinyin_end_get_phrases(iter);
fclose (dictfile);
return TRUE;
}