Просмотр исходного кода

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

ambrop7 13 лет назад
Родитель
Сommit
08c662612c
1 измененных файлов с 1 добавлено и 1 удалено
  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)
     ASSERT(out_nodeidx)
     
     
     if (o->count == o->capacity) {
     if (o->count == o->capacity) {
-        if (o->capacity > INT_MAX / 2) {
+        if (o->capacity > INT_MAX / 2 || o->capacity > SIZE_MAX / 2) {
             return 0;
             return 0;
         }
         }
         int newcap = 2 * o->capacity;
         int newcap = 2 * o->capacity;