Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diff::merge() causes double free #964

Open
slack-coder opened this issue Jul 5, 2023 · 2 comments
Open

Diff::merge() causes double free #964

slack-coder opened this issue Jul 5, 2023 · 2 comments
Labels
upstream An upstream issue with libgit2

Comments

@slack-coder
Copy link

slack-coder commented Jul 5, 2023

The library fails with a double free when merging two Diff's built from buffers. Is this intended to be supported?

Cargo.toml

[dependencies.git2]
version = "0.17.2"
default-features = false
features = ["vendored-libgit2"]
        use git2;

        let diff_a: &str = r#"
diff --git a/README.md b/README.md
index 18fb8328..ce60f40c 100644
--- a/README.md
+++ b/README.md
@@ -4,1 +4,2 @@ componentwise
 reusing
+proverb
"#
        .trim_start();
        let mut diff_a = git2::Diff::from_buffer(diff_a.as_bytes()).unwrap();

        let diff_b: &str = r#"
diff --git a/README.md b/README.md
index 18fb8328..ce60f40c 100644
--- a/README.md
+++ b/README.md
@@ -4,2 +4,3 @@ componentwise
 reusing
 proverb
+offended
"#
        .trim_start();
        let diff_b = git2::Diff::from_buffer(diff_b.as_bytes()).unwrap();

        diff_a.merge(&diff_b).expect("merge diff from buffers");

Results in:

free(): double free detected in tcache 2
error: test failed, to rerun pass `-p radicle-cli --lib`

Edit: simplified example and added Cargo information

@cloudhead
Copy link

You may want to open this on libgit2 directly, as the frees are probably coming from there.

@ehuss
Copy link
Contributor

ehuss commented Jul 8, 2023

I filed an upstream issue at libgit2/libgit2#6588.

@ehuss ehuss added the upstream An upstream issue with libgit2 label Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream An upstream issue with libgit2
Projects
None yet
Development

No branches or pull requests

3 participants