summaryrefslogtreecommitdiffstats
path: root/src/PYLibPinyin.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/PYLibPinyin.cc')
-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;
}