mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-06 00:30:16 +00:00
diff_tform: fix potential NULL pointer access
When the user passes in a diff which has no repository associated we may call `git_config__get_int_force` with a NULL-pointer configuration. Even though `git_config__get_int_force` is designed to swallow errors, it is not intended to be called with a NULL pointer configuration. Fix the issue by only calling `git_config__get_int_force` only when configuration could be retrieved from the repository.
This commit is contained in:
parent
486302d6af
commit
1a8c11f443
@ -261,7 +261,7 @@ static int normalize_find_opts(
|
|||||||
if (!given ||
|
if (!given ||
|
||||||
(given->flags & GIT_DIFF_FIND_ALL) == GIT_DIFF_FIND_BY_CONFIG)
|
(given->flags & GIT_DIFF_FIND_ALL) == GIT_DIFF_FIND_BY_CONFIG)
|
||||||
{
|
{
|
||||||
if (diff->repo) {
|
if (cfg) {
|
||||||
char *rule =
|
char *rule =
|
||||||
git_config__get_string_force(cfg, "diff.renames", "true");
|
git_config__get_string_force(cfg, "diff.renames", "true");
|
||||||
int boolval;
|
int boolval;
|
||||||
@ -318,8 +318,10 @@ static int normalize_find_opts(
|
|||||||
#undef USE_DEFAULT
|
#undef USE_DEFAULT
|
||||||
|
|
||||||
if (!opts->rename_limit) {
|
if (!opts->rename_limit) {
|
||||||
|
if (cfg) {
|
||||||
opts->rename_limit = git_config__get_int_force(
|
opts->rename_limit = git_config__get_int_force(
|
||||||
cfg, "diff.renamelimit", DEFAULT_RENAME_LIMIT);
|
cfg, "diff.renamelimit", DEFAULT_RENAME_LIMIT);
|
||||||
|
}
|
||||||
|
|
||||||
if (opts->rename_limit <= 0)
|
if (opts->rename_limit <= 0)
|
||||||
opts->rename_limit = DEFAULT_RENAME_LIMIT;
|
opts->rename_limit = DEFAULT_RENAME_LIMIT;
|
||||||
|
Loading…
Reference in New Issue
Block a user