From d4b7aa31a0261af21c8cdf36717119175280ca76 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 14 Jul 2014 13:00:48 +0800 Subject: fixes method selectCandidate --- src/ZYZPhoneticSection.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/ZYZPhoneticSection.cc') diff --git a/src/ZYZPhoneticSection.cc b/src/ZYZPhoneticSection.cc index a240a68..99d6213 100644 --- a/src/ZYZPhoneticSection.cc +++ b/src/ZYZPhoneticSection.cc @@ -101,6 +101,12 @@ PhoneticSection::selectCandidate (guint index) guint16 prev_pos = m_cursor, cur_pos = 0; ChewingKeyRest * key_rest = NULL; + guint len = 0; + zhuyin_get_n_candidate (m_instance, &len); + + if (index >= len) + return 0; + lookup_candidate_t * candidate = NULL; zhuyin_get_candidate (m_instance, index, &candidate); @@ -111,7 +117,6 @@ PhoneticSection::selectCandidate (guint index) offset = zhuyin_choose_candidate (m_instance, offset, candidate); - guint len = 0; zhuyin_get_n_zhuyin (m_instance, &len); if (offset < len) { -- cgit