Browse Source

structure: BStringTrie: fix an overflow just introduced, in case int is bigger than size_t

ambrop7 13 năm trước cách đây
mục cha
commit
08c662612c
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  1. 1 1
      structure/BStringTrie.h

+ 1 - 1
structure/BStringTrie.h

@@ -66,7 +66,7 @@ static int BStringTrie__new_node (BStringTrie *o, int *out_nodeidx)
     ASSERT(out_nodeidx)
     
     if (o->count == o->capacity) {
-        if (o->capacity > INT_MAX / 2) {
+        if (o->capacity > INT_MAX / 2 || o->capacity > SIZE_MAX / 2) {
             return 0;
         }
         int newcap = 2 * o->capacity;