Commit 952bf8d2 authored by Tyler Wanek's avatar Tyler Wanek Committed by GitHub

Merge pull request #1332 from kurtb/master

Fix git_tree_entry double free
parents 20d40d65 67fc71da
......@@ -2658,19 +2658,22 @@
"functions": {
"git_tree_entry_byid": {
"return": {
"ownedByThis": true
"ownedByThis": true,
"selfFreeing": false
}
},
"git_tree_entry_byindex": {
"jsFunctionName": "_entryByIndex",
"return": {
"ownedByThis": true
"ownedByThis": true,
"selfFreeing": false
}
},
"git_tree_entry_byname": {
"jsFunctionName": "_entryByName",
"return": {
"ownedByThis": true
"ownedByThis": true,
"selfFreeing": false
}
},
"git_tree_entrycount": {
......@@ -2691,6 +2694,21 @@
"git_treebuilder_filter": {
"ignore": true
},
"git_treebuilder_get": {
"return": {
"selfFreeing": false,
"ownedByThis": true
}
},
"git_treebuilder_insert": {
"isAsync": false,
"args": {
"out": {
"selfFreeing": false,
"ownedByThis": true
}
}
},
"git_treebuilder_write": {
"args": {
"id": {
......
......@@ -5,10 +5,14 @@ var promisify = require("promisify-node");
var readDir = promisify(fs.readdir);
var local = path.join.bind(path, __dirname);
var leakTest = require("../utils/leak_test");
describe("TreeBuilder", function(){
var Git = require("../../");
var reposPath = local("../repos/workdir");
var oid = "111dd657329797f6165f52f5085f61ac976dcf04";
//setup test repo each test
beforeEach(function() {
var test = this;
......@@ -76,4 +80,19 @@ describe("TreeBuilder", function(){
return Git.Tree.lookup(test.repo, newTreeEntry.oid());
});
});
it("does not leak inserts", function() {
var test = this;
// The underlying C++ git_tree_entry is owned by the treebuilder that
// creates it. But since git_tree_entry is duplicable the generator will
// duplicate it and mark it as self freeing.
// Validate this with the leakTest.
return leakTest(Git.TreeEntry, function() {
return Git.Treebuilder.create(test.repo, null)
.then(function(builder) {
return builder.insert("test", oid, Git.TreeEntry.FILEMODE.BLOB);
});
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment