From f20d0892a471f4661c71b160050b32668151c94c Mon Sep 17 00:00:00 2001 From: Choe Hwanjin Date: Sat, 25 Dec 2010 16:33:04 +0900 Subject: [PATCH] =?utf8?q?hangul=5Fcombination=5Fcombine()=20=ED=95=A8?= =?utf8?q?=EC=88=98=EC=9D=98=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit hangul_combination_combine() 함수의 비교함수에서 두 key 값을 단순히 뺄셈연산하여 리턴하게 되면 두수의 크기차 signed int를 넘어서는 경우에 음수로 연산될 수 있어서 위험하다. 부등호를 이용하여 비교연산으로 처리한다. Unicode 5.2에서 추가된 자모들중 U+A960, U+D7B0 영역의 문자들을 조합하지 못하는 문제 수정 git-svn-id: http://kldp.net/svn/hangul/libhangul/trunk@241 8f00fcd2-89fc-0310-932e-b01be5b65e01 --- hangul/hangulinputcontext.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hangul/hangulinputcontext.c b/hangul/hangulinputcontext.c index 953240f..1b3c707 100644 --- a/hangul/hangulinputcontext.c +++ b/hangul/hangulinputcontext.c @@ -483,7 +483,15 @@ hangul_combination_cmp(const void* p1, const void* p2) { const HangulCombinationItem *item1 = p1; const HangulCombinationItem *item2 = p2; - return item1->key - item2->key; + + /* key는 unsigned int이므로 단순히 빼서 리턴하면 안된다. + * 두 수의 차가 큰 경우 int로 변환하면서 음수가 될 수 있다. */ + if (item1->key < item2->key) + return -1; + else if (item1->key > item2->key) + return 1; + else + return 0; } ucschar -- 2.7.4