]> git.lizzy.rs Git - bit-set.git/commit
properly implement shrink_to_fit.
authorAria Beingessner <a.beingessner@gmail.com>
Sat, 23 Jul 2022 00:30:52 +0000 (20:30 -0400)
committerAria Beingessner <a.beingessner@gmail.com>
Sat, 23 Jul 2022 00:33:23 +0000 (20:33 -0400)
commitf3cab77c377c94e13eb6e6e079089602ddd1eaf5
tree5e577dcd4f1c8e8e5bf91fec8e07399798f6c47f
parent39cdb58891a3387fc959ba866f9e42b6b01b2bc2
properly implement shrink_to_fit.

For whatever reason it treated 1 as the minimum number of blocks and would corrupt
itself if it was already at 0 blocks. It also never actualy did a shrink_to_fit,
it just told the underlying bit_vec that it had less initialized blocks.

So all around just a buggy mess. Thankfully although the bit_set code is 'unsafe'
it wasn't ever actually a memory-safety issue. The unsafe here is a reservation
from bit_vec to be more dangerous, but the implementation never actually has any
unsafe code of its own, so this was just state corruption that would crash,
similar to feeding a bad Ord impl into a BTreeMap. Bad, but not a vulnerability.

Fixes #25
src/lib.rs