- Fix a segfault with some words containing vu. (#452779)

This commit is contained in:
Akira TAGOH 2008-06-27 10:11:26 +00:00
commit db5ad5eec8
2 changed files with 62 additions and 1 deletions

View file

@ -0,0 +1,56 @@
diff -pruN anthy-9100e.orig/src-splitter/metaword.c anthy-9100e/src-splitter/metaword.c
--- anthy-9100e.orig/src-splitter/metaword.c 2007-06-18 08:27:38.000000000 +0900
+++ anthy-9100e/src-splitter/metaword.c 2008-06-27 11:53:55.000000000 +0900
@@ -17,6 +17,7 @@
#include <anthy/record.h>
#include <anthy/splitter.h>
+#include <anthy/xchar.h>
#include <anthy/xstr.h>
#include <anthy/segment.h>
#include <anthy/segclass.h>
@@ -158,6 +159,18 @@ get_surrounding_text(struct splitter_con
xs_post->len = post_len;
}
+static int
+count_vu(xstr *xs)
+{
+ int i, r = 0;
+ for (i = 0; i < xs->len; i++) {
+ if (xs->str[i] == KK_VU) {
+ r++;
+ }
+ }
+ return r;
+}
+
/*
* 複合語であるwlからn番めの部分を取り出してmwにする
*/
@@ -177,8 +190,12 @@ make_compound_nth_metaword(struct splitt
get_surrounding_text(sc, wl, &xs_pre, &xs_post);
for (i = 0; i <= nth; ++i) {
+ xstr part;
from += len;
len = anthy_compound_get_nth_segment_len(ce, i);
+ part.str = sc->ce[from].c;
+ part.len = len;
+ len -= count_vu(&part);
if (i == 0) {
len += xs_pre.len;
}
@@ -742,7 +759,11 @@ make_metaword_with_depchar(struct splitt
int len = mw ? mw->len : 0;
/* metawordの直後の文字の種類を調べる */
- int type = anthy_get_xchar_type(*sc->ce[from + len].c);
+ int type;
+ if (sc->char_count <= from + len) {
+ return;
+ }
+ type = anthy_get_xchar_type(*sc->ce[from + len].c);
if (!(type & XCT_SYMBOL) &&
!(type & XCT_PART)) {
return;

View file

@ -1,6 +1,6 @@
Name: anthy
Version: 9100e
Release: 2%{?dist}
Release: 3%{?dist}
# The entire source code is LGPLv2+ and dictionaries is GPLv2.
License: LGPLv2+ and GPLv2
URL: http://sourceforge.jp/projects/anthy/
@ -11,6 +11,7 @@ BuildRequires: xemacs
Source0: http://prdownloads.sourceforge.jp/anthy/29142/anthy-%{version}.tar.gz
Source1: anthy-init.el
Patch0: anthy-9100e-fix-segfault-vu.patch
Summary: Japanese character set input library
Group: System Environment/Libraries
@ -50,6 +51,7 @@ character set on XEmacs.
%prep
%setup -q #-a 2
%patch0 -p1 -b 0-vu
#cp alt-cannadic-%{altcannadicver}/* alt-cannadic/
%build
@ -112,6 +114,9 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/xemacs/site-packages/lisp/site-start.d/anthy-init.el
%changelog
* Fri Jun 27 2008 Akira TAGOH <tagoh@redhat.com> - 9100e-3
- Fix a segfault with some words containing vu. (#452779)
* Tue Feb 12 2008 Akira TAGOH <tagoh@redhat.com> - 9100e-2
- Rebuild for gcc-4.3.