Skip to content

iteration will panic on empty vectors #46

Closed

Description

@bcantrill

(This issue is fixed by #44 -- but I wanted to explicitly file an issue in case others hit this.)

We are heavy users of MultiMap in Humility (thank you!), and we hit an issue where we panicked in MultiMap iteration on some archives for some operations. This is replicated with the following program:

use multimap::MultiMap;

fn main() {
    let mut m = MultiMap::new();

    m.insert("foo", true);
    m.insert("bar", true);
    m.insert("baz", true);

    for (n, _) in m.iter() {
        println!("{n}");
    }

    m.get_vec_mut("baz").expect("wat").pop();

    for (n, _) in m.iter() {
        println!("{n}");
    }
}

This will die when run:

foo
bar
baz
foo
bar
thread 'main' panicked at /home/bmc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/multimap-0.8.3/src/lib.rs:822:46:
index out of bounds: the len is 0 but the index is 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I have verified that #44 fixes this and results in the expected behavior -- so it would be great to get that merged. And thank you again for MultiMap!

Activity

  1. havarnov commented on Oct 23, 2023

    @havarnov
    Owner

    Thanks for filing an issue. I'm sorry the PR have been in limbo for such a long time :/

  2. havarnov commented on Oct 23, 2023

    @havarnov
    Owner

    Fixed in v0.9.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions