File tree 1 file changed +6
-0
lines changed
1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -161,8 +161,12 @@ class chashtable : private HashProc, private EqProc {
161
161
unsigned curr_cellar = (m_capacity - m_slots);
162
162
unsigned new_slots = m_slots * 2 ;
163
163
unsigned new_cellar = curr_cellar * 2 ;
164
+ if (new_slots < m_slots || new_cellar < curr_cellar)
165
+ throw default_exception (" table overflow" );
164
166
while (true ) {
165
167
unsigned new_capacity = new_slots + new_cellar;
168
+ if (new_capacity < new_slots)
169
+ throw default_exception (" table overflow" );
166
170
cell * new_table = alloc_table (new_capacity);
167
171
cell * next_cell = copy_table (m_table, m_slots, m_capacity,
168
172
new_table, new_slots, new_capacity,
@@ -179,6 +183,8 @@ class chashtable : private HashProc, private EqProc {
179
183
return ;
180
184
}
181
185
dealloc_vect (new_table, new_capacity);
186
+ if (2 *new_cellar < new_cellar)
187
+ throw default_exception (" table overflow" );
182
188
new_cellar *= 2 ;
183
189
}
184
190
}
You can’t perform that action at this time.
0 commit comments