summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChoe Hwanjin <choe.hwanjin@gmail.com>2010-12-25 16:33:04 +0900
committerChoe Hwanjin <choe.hwanjin@gmail.com>2010-12-25 16:33:04 +0900
commitf20d0892a471f4661c71b160050b32668151c94c (patch)
tree3c10f7b990d3969de7135a1ea08e70658cdddf2b
parentc2a5e330a4e809d1c89c03d847eb23dc1154f610 (diff)
downloadlibhangul-f20d0892a471f4661c71b160050b32668151c94c.tar.gz
hangul_combination_combine() 함수의 버그 수정
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
-rw-r--r--hangul/hangulinputcontext.c10
1 files changed, 9 insertions, 1 deletions
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