Skip to content

Lookup a non existent commit crashes the process. #353

Description

@addisonj

I am doing some analysis of a codebase over time using nodegit, I am getting commits from an outside source that may no longer exist.

Doing Commit.lookup says it should be safe, but if I do a lookup with an invalid commit (but a full sha), I get the following error:

good repo
[Error: Object not found - failed to find pack entry (b5e13cc50f98d9a045bebadffacf396b9ee49ad5)]
node(16924,0x7fff73d77300) malloc: *** error for object 0x100d02be0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

Here is some example code that causes the failure:

var nodegit = require("nodegit")
var Repo = nodegit.Repository
var Commit = nodegit.Commit

Repo.open("/path/to/myrepo").then(function(repo) {
  console.log("good repo")
  // missing, but valid full length, sha
  return Commit.lookup(repo, "b5e13cc50f98d9a045bebadffacf396b9ee49ad5").then(function(commit) {
    console.log(commit.message())
  }, function(err) { console.log(err); throw err})
}, function(err) { console.log(err); throw err })

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