Skip to content

Commit

Permalink
#207: Argument cannot be negative
Browse files Browse the repository at this point in the history
  • Loading branch information
kkos committed Sep 21, 2020
1 parent 98674c8 commit 27a7ce9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/st.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ st_init_table_with_size(type, size)
#endif

size = new_size(size); /* round up to prime number */
if (size <= 0) return 0;

tbl = alloc(st_table);
if (tbl == 0) return 0;
Expand Down Expand Up @@ -318,10 +319,13 @@ rehash(table)
register st_table *table;
{
register st_table_entry *ptr, *next, **new_bins;
int i, old_num_bins = table->num_bins, new_num_bins;
int i, new_num_bins, old_num_bins;
unsigned int hash_val;

new_num_bins = new_size(old_num_bins+1);
old_num_bins = table->num_bins;
new_num_bins = new_size(old_num_bins + 1);
if (new_num_bins <= 0) return ;

new_bins = (st_table_entry**)Calloc(new_num_bins, sizeof(st_table_entry*));
if (new_bins == 0) {
return ;
Expand Down

0 comments on commit 27a7ce9

Please sign in to comment.