From: Thomas Bachem via GitGitGadget Date: Tue, 10 Nov 2026 07:36:37 GMT Subject: [PATCH v2 07/15] blame: handle NULL values for color.blame.* config Message-ID: <25843b43bfa414319a8cb36cc69638dcaf7c5edc.1794296205.git.gitgitgadget@gmail.com> In-Reply-To: From: Thomas Bachem A color.blame.repeatedLines or color.blame.highlightRecent without a value makes "git blame" segfault: git_blame_config() passes the NULL value to strlen() or to parse_color_fields(). Reject a missing value with config_error_nonbool(), as git_blame_config() already does for blame.date and blame.coloring. Assisted-by: Claude Fable 5.1 Signed-off-by: Thomas Bachem --- builtin/blame.c | 4 ++++ t/t8012-blame-colors.sh | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/builtin/blame.c b/builtin/blame.c index 1e753a0b60..15cacd1002 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -783,12 +783,16 @@ static int git_blame_config(const char *var, const char *value, return 0; } if (!strcmp(var, "color.blame.repeatedlines")) { + if (!value) + return config_error_nonbool(var); if (color_parse_mem(value, strlen(value), repeated_meta_color)) warning(_("invalid value for '%s': '%s'"), "color.blame.repeatedLines", value); return 0; } if (!strcmp(var, "color.blame.highlightrecent")) { + if (!value) + return config_error_nonbool(var); parse_color_fields(value); return 0; } diff --git a/t/t8012-blame-colors.sh b/t/t8012-blame-colors.sh index d2653b3c31..5eeb7338a3 100755 --- a/t/t8012-blame-colors.sh +++ b/t/t8012-blame-colors.sh @@ -69,4 +69,11 @@ test_expect_success 'blame color by age: new code is different' ' test_grep qfunc colored ' +test_expect_success 'color.blame.repeatedLines and highlightRecent need a value' ' + test_must_fail git -c color.blame.repeatedLines blame hello.c 2>err && + test_grep "missing value for .color.blame.repeatedlines." err && + test_must_fail git -c color.blame.highlightRecent blame hello.c 2>err && + test_grep "missing value for .color.blame.highlightrecent." err +' + test_done -- gitgitgadget