Skip to content

Segmentation fault when collecting config entries in vector #836

Closed
@fin-ger

Description

@fin-ger

Hi,

the below code snipped creates a segmentation fault:

fn main() {
    let repo = git2::Repository::open(".").unwrap();
    let config = repo.config().unwrap();
    let entries_iter = config.entries(None).unwrap();
    let entries: Vec<_> = entries_iter.map(Result::unwrap).collect();

    for entry in &entries {
        println!("name: {}", entry.name().unwrap());
    }
}

Output:

$ ./target/debug/git-segfault
[1]    498461 segmentation fault (core dumped)

The issue appears when collecting the entries of ConfigEntries and then iterating over them. The following code works just fine:

fn main() {
    let repo = git2::Repository::open(".").unwrap();
    let config = repo.config().unwrap();

    for entry in &config.entries(None).unwrap() {
        println!("name: {}", entry.unwrap().name().unwrap());
    }
}

Thank you for any help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions