FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix git_tree_entry double free by kurtb · Pull Request #1332 · nodegit/nodegit · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (1) .json  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
24 changes: 21 additions & 3 deletions generate/input/descriptor.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2529,19 +2529,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": {
Expand All @@ -2562,6 +2565,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": {
Expand Down
19 changes: 19 additions & 0 deletions test/tests/treebuilder.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
});
});
});

Back | FazBrowse Home | New Git URL