summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChoe Hwanjin <choe.hwanjin@gmail.com>2008-02-24 11:02:39 +0900
committerChoe Hwanjin <choe.hwanjin@gmail.com>2008-02-24 11:02:39 +0900
commit20760fa619dad1b0a5f4d3d31b340c7598f65566 (patch)
treeb202fbca4d3effcabf603a0eee9170d39edea8a5
parent7624d78733d9f1344a4c3f093d597fed95d2340a (diff)
downloadlibhangul-20760fa619dad1b0a5f4d3d31b340c7598f65566.tar.gz
HanjaList와 PtrVector의 크기의 한계값을 SIZE_MAX를 사용하여 체크
git-svn-id: http://kldp.net/svn/hangul/libhangul/trunk@164 8f00fcd2-89fc-0310-932e-b01be5b65e01
-rw-r--r--hangul/hanja.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/hangul/hanja.c b/hangul/hanja.c
index 2db6c65..f6dfea0 100644
--- a/hangul/hanja.c
+++ b/hangul/hanja.c
@@ -333,7 +333,10 @@ ptr_vector_get_length(PtrVector* vector)
static void
ptr_vector_append(PtrVector* vector, void* data)
{
- if (vector->alloc < vector->len + 1 && vector->alloc < UINT_MAX / 2) {
+ if (vector->alloc * sizeof(vector->ptrs[0]) >= SIZE_MAX / 2)
+ return;
+
+ if (vector->alloc < vector->len + 1) {
size_t alloc = vector->alloc * 2;
void** ptrs;
@@ -457,7 +460,10 @@ hanja_list_new(const char *key)
static void
hanja_list_reserve(HanjaList* list, size_t n)
{
- if (list->alloc < list->len + n && list->alloc < UINT_MAX / 2) {
+ if (list->alloc * sizeof(list->items[0]) >= SIZE_MAX / 2)
+ return;
+
+ if (list->alloc < list->len + n) {
const Hanja** data;
size_t size = list->alloc;