{{ message }}
Repository navigation
refdb: initialize db in git_refdb_open - #7430
Open
cristianchiriac wants to merge 1 commit into
Open
cristianchiriac wants to merge 1 commit into
cristianchiriac wants to merge 1 commit into
Conversation
git_refdb_new does not set its output when its allocation fails, so the error path in git_refdb_open freed an uninitialized pointer. Fixes libgit2#7421
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #7421.
In
git_refdb_open,dbwas never initialized, andgit_refdb_newdoesn't set its output when its allocation fails. The error path then calledgit_refdb_free(db)on an uninitialized pointer.dbnow starts asNULL, whichgit_refdb_freeignores. This is the fix suggested in the issue.Test:
refs::oom::lookup_fails_or_finds_headopenstestrepo.gitand looks upHEAD, which opens the refdb. The lookup runs with an allocator that fails the Nth allocation, for every N until no allocation fails. Each lookup must either report an error or findHEAD->refs/heads/master. This is the same pattern asblame::oomin #7425 andconfig::oomin #7429. The repository is opened with the normal allocator, because opening it under the failing one first runs into #7416.To be upfront about it: on my MinGW build, this test also passes without the fix, because the uninitialized stack slot happens to be zero there. It does run the failing
git_refdb_newpath, so memory sanitizer builds and builds where the slot holds garbage (the issue reproduces it on Linux at-O0) will catch a regression.All tests in
-srefspass (MinGW gcc 16, Windows 11).