Skip to content

git_tree_entry should not be selfFreeing #1333

Description

@kurtb

git_tree_entry is marked as self freeing. But libgit2 only requires free'ing these in cases where the entry is retrieved from git_tree_entry_dup or git_tree_entry_bypath. Neither of which is exposed by nodegit. This can lead to memory corruption and/or double free.

I created #1332 to fix the issue.

Fairly easy to reproduce with the below running in a loop.

const builder = await git.Treebuilder.create(repository, null);

const oid = git.Oid.fromString("b45ef6fec89518d314f546fd6c3025367b721684");
for (let i = 0; i < 100; i++) {
    builder.insert(
        moniker.choose(),
        oid,
        parseInt("100644", 8));
}
builder.write();

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