Fixes crashes for Full Pinyin and Bopomofo

This commit is contained in:
Peng Wu 2016-08-09 12:57:47 +08:00
parent 348286933e
commit 76e469beea
2 changed files with 37 additions and 2 deletions

View File

@ -0,0 +1,32 @@
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index ac72623..6d8738c 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -2506,7 +2506,7 @@ static bool _get_char_offset_recur(pinyin_instance_t * instance,
gfloat pinyin_poss = item.get_pronunciation_possibility(&key);
if (pinyin_poss < FLT_EPSILON)
- return false;
+ continue;
++length;
@@ -2530,6 +2530,9 @@ bool pinyin_get_character_offset(pinyin_instance_t * instance,
pinyin_context_t * context = instance->m_context;
PhoneticKeyMatrix & matrix = instance->m_matrix;
+ if (0 == matrix.size())
+ return false;
+
assert(offset < matrix.size());
_check_offset(matrix, offset);
@@ -2973,7 +2976,7 @@ static bool _remember_phrase_recur(pinyin_instance_t * instance,
gfloat pinyin_poss = item.get_pronunciation_possibility(&key);
if (pinyin_poss < FLT_EPSILON)
- return false;
+ continue;
/* push value */
g_array_append_val(cached_keys, key);

View File

@ -1,8 +1,8 @@
%global snapshot 0
%global snapshot 1
Name: libpinyin
Version: 1.5.92
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Library to deal with pinyin
License: GPLv2+
@ -92,6 +92,9 @@ find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
%changelog
* Tue Aug 9 2016 Peng Wu <pwu@redhat.com> - 1.5.92-2
- Fixes crashes for Full Pinyin and Bopomofo
* Tue Aug 2 2016 Peng Wu <pwu@redhat.com> - 1.5.92-1
- Update to 1.5.92