Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1a8c11f

Browse files
committed
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.
1 parent 486302d commit 1a8c11f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/diff_tform.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static int normalize_find_opts(
261261
if (!given ||
262262
(given->flags & GIT_DIFF_FIND_ALL) == GIT_DIFF_FIND_BY_CONFIG)
263263
{
264-
if (diff->repo) {
264+
if (cfg) {
265265
char *rule =
266266
git_config__get_string_force(cfg, "diff.renames", "true");
267267
int boolval;
@@ -318,8 +318,10 @@ static int normalize_find_opts(
318318
#undef USE_DEFAULT
319319

320320
if (!opts->rename_limit) {
321-
opts->rename_limit = git_config__get_int_force(
322-
cfg, "diff.renamelimit", DEFAULT_RENAME_LIMIT);
321+
if (cfg) {
322+
opts->rename_limit = git_config__get_int_force(
323+
cfg, "diff.renamelimit", DEFAULT_RENAME_LIMIT);
324+
}
323325

324326
if (opts->rename_limit <= 0)
325327
opts->rename_limit = DEFAULT_RENAME_LIMIT;

0 commit comments

Comments
 (0)