Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
probably overflow of unsigned for large capacity
  • Loading branch information
NikolajBjorner committed Feb 14, 2024
1 parent 155dfb1 commit 2b14793
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/util/chashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,12 @@ class chashtable : private HashProc, private EqProc {
unsigned curr_cellar = (m_capacity - m_slots);
unsigned new_slots = m_slots * 2;
unsigned new_cellar = curr_cellar * 2;
if (new_slots < m_slots || new_cellar < curr_cellar)
throw default_exception("table overflow");
while (true) {
unsigned new_capacity = new_slots + new_cellar;
if (new_capacity < new_slots)
throw default_exception("table overflow");
cell * new_table = alloc_table(new_capacity);
cell * next_cell = copy_table(m_table, m_slots, m_capacity,
new_table, new_slots, new_capacity,
Expand All @@ -179,6 +183,8 @@ class chashtable : private HashProc, private EqProc {
return;
}
dealloc_vect(new_table, new_capacity);
if (2*new_cellar < new_cellar)
throw default_exception("table overflow");
new_cellar *= 2;
}
}
Expand Down

0 comments on commit 2b14793

Please sign in to comment.