-
Notifications
You must be signed in to change notification settings - Fork 425
Open
Description
If Index::add_all()
is called with an empty (&[]
) pathspecs
slice and Some(...)
callback then it will crash.
If pathspecs
is set to anything (eg &[*]
) or cb
is set to None
then it runs without a crash.
I suspect the issue is that it's crashing trying to create the matched_pathspec
argument for the callback and that the type of that argument should be changed to be an Option<&[u8]>
.
Full steps to reproduce:
$ cargo new git2-crash
$ cd git2-crash
$ echo 'git2 = "0.13.6"' >> Cargo.toml
$ cat >|src/main.rs <<EOF
fn main() {
let pathspecs: &[&str] = &[];
git2::Repository::open(".")
.unwrap()
.index()
.unwrap()
.add_all(pathspecs, Default::default(), Some(&mut |_path, _matched_pathspec| 0))
.unwrap();
}
EOF
$ cargo run
Updating crates.io index
...
Compiling git2-crash v0.1.0 (/Users/cpick/src/delme/git2-crash)
Finished dev [unoptimized + debuginfo] target(s) in 14.64s
Running `target/debug/git2-crash`
Segmentation fault: 11
Metadata
Metadata
Assignees
Labels
No labels