CompareIntegerMaps icon indicating copy to clipboard operation
CompareIntegerMaps copied to clipboard

Insert() bug

Open mateofio opened this issue 12 years ago • 1 comments

Unless I'm overlooking something there appears to be a bug in your HashTable::Insert() method.

First you search for the Cell with matching key or an empty cell with key == 0. Then if key == 0 you do a resize check before doing the insertion.

The problem is once you resize the array, the cell pointer you had before now points to garbage. After resizing you need to redo the lookup.

mateofio avatar Feb 20 '13 03:02 mateofio

And he does, look at the break just after the resize.

lauper avatar Jun 08 '13 20:06 lauper