Fixes crash in Double Pinyin

This commit is contained in:
Peng Wu 2017-02-28 11:09:10 +08:00
parent 53e95c3b0e
commit 52c0c70cfd
2 changed files with 32 additions and 2 deletions

View File

@ -0,0 +1,27 @@
diff --git a/src/include/memory_chunk.h b/src/include/memory_chunk.h
index 83b8ad9..044fa0d 100644
--- a/src/include/memory_chunk.h
+++ b/src/include/memory_chunk.h
@@ -60,7 +60,7 @@ private:
char * m_allocated; //one data pass the end.
free_func_t m_free_func;
- const guint32 header = sizeof(guint32) * 2;
+ const gint32 header = sizeof(guint32) * 2;
private:
void freemem(){
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index 1a5132e..57defcc 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -1172,6 +1172,9 @@ bool pinyin_get_sentence(pinyin_instance_t * instance,
pinyin_context_t * & context = instance->m_context;
NBestMatchResults & results = instance->m_nbest_results;
+ if (0 == results.size())
+ return false;
+
MatchResult result = NULL;
assert(index < results.size());
assert(results.get_result(index, result));

View File

@ -1,8 +1,8 @@
%global snapshot 0
%global snapshot 1
Name: libpinyin
Version: 1.9.91
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Library to deal with pinyin
License: GPLv3+
@ -92,6 +92,9 @@ find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
%changelog
* Tue Feb 28 2017 Peng Wu <pwu@redhat.com> - 1.9.91-2
- Fixes crash in Double Pinyin
* Tue Feb 14 2017 Peng Wu <pwu@redhat.com> - 1.9.91-1
- Update to 1.9.91
- multiple sentence candidates