aboutsummaryrefslogtreecommitdiffstats
path: root/src/virtualkeyboard/3rdparty
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2015-04-08 13:53:06 +0300
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2015-04-09 10:40:42 +0300
commit6fe7d1f903046de1b436d2b34126d595afe2d5cd (patch)
tree7dc8a028d788ac85a7d63537f7a7a47be61df3bb /src/virtualkeyboard/3rdparty
parent7d0fc43e9848381a7dc5c66e9c078f3a1881f6f1 (diff)
Fix crash in pinyin ime if the user dictionary cannot be opened
This change fixes a crash caused by dangling pointer. The crash happens the next time the user dictionary is flushed after it fails to open the file. Change-Id: If1f51279a8d42f01f08879f0cefcef541d0beff8 Reviewed-by: Rainer Keller <rainer.keller@theqtcompany.com>
Diffstat (limited to 'src/virtualkeyboard/3rdparty')
-rw-r--r--src/virtualkeyboard/3rdparty/pinyin/share/userdict.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/virtualkeyboard/3rdparty/pinyin/share/userdict.cpp b/src/virtualkeyboard/3rdparty/pinyin/share/userdict.cpp
index a3db8884..f5f9371b 100644
--- a/src/virtualkeyboard/3rdparty/pinyin/share/userdict.cpp
+++ b/src/virtualkeyboard/3rdparty/pinyin/share/userdict.cpp
@@ -309,6 +309,7 @@ bool UserDict::load_dict(const char *file_name, LemmaIdType start_id,
return true;
error:
free((void*)dict_file_);
+ dict_file_ = NULL;
start_id_ = 0;
return false;
}
@@ -1021,6 +1022,8 @@ bool UserDict::remove_lemma(LemmaIdType lemma_id) {
void UserDict::flush_cache() {
LemmaIdType start_id = start_id_;
+ if (!dict_file_)
+ return;
const char * file = strdup(dict_file_);
if (!file)
return;