You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** The commit author, or NULL for the default. */
constgit_signature*author;
/** The committer, or NULL for the default. */
constgit_signature*committer;
Actual behavior
The default committer is not used, leaving the internal committer variable of git_commit_create_from_stage uninitialized, leading to EXC_BAD_ACCESS or similar issues.
if (git_signature_default(&default_signature, repo) <0)
goto done;
if (!author)
author=default_signature;
if (!committer)
committer=default_signature;
}
However, if (author = opts.author) == NULL, the condition short-circuits and committer = opts.committer is never run, leaving committer uninitialized. The code
will thus most likely not be executed, meaning the default committer is never set and instead the uninitialized committer is used in the following code.
Thanks for the addition of git_commit_create_from_stage, this is a handy shortcut!
The text was updated successfully, but these errors were encountered:
Reproduction steps
Call
git_commit_create_from_stage
with eithergiven_opts
ofNULL
orgiven_opts
with bothauthor
andcommitter
ofNULL
.Expected behavior
The default author and committer are used, as per
libgit2/include/git2/commit.h
Lines 409 to 413 in d74d491
Actual behavior
The default committer is not used, leaving the internal
committer
variable ofgit_commit_create_from_stage
uninitialized, leading toEXC_BAD_ACCESS
or similar issues.Version of libgit2 (release number or SHA1)
d74d491 (1.8.0)
Operating system(s) tested
macOS 14.2.1 (23C71)
Debugging
The variables are set up here:
libgit2/src/libgit2/commit.c
Lines 1089 to 1097 in d74d491
and checked here:
libgit2/src/libgit2/commit.c
Lines 1110 to 1120 in d74d491
However, if
(author = opts.author) == NULL
, the condition short-circuits andcommitter = opts.committer
is never run, leavingcommitter
uninitialized. The codelibgit2/src/libgit2/commit.c
Lines 1118 to 1119 in d74d491
will thus most likely not be executed, meaning the default committer is never set and instead the uninitialized
committer
is used in the following code.Thanks for the addition of
git_commit_create_from_stage
, this is a handy shortcut!The text was updated successfully, but these errors were encountered: