[PATCH 1/3] pretty.c: fix null pointer dereference
- From
Mirko Faina <mroik@delayed.space>
- Date
- Feb 24, 2026, 04:03 UTC
- Message-ID
- <20260224040400.751247-2-mroik@delayed.space>
- In-Reply-To
- <20260220230633.132213-1-mroik@delayed.space>
commit_format_is_empty() is used to check whether "user_format" is set to a value. Unfortunately this function crashes the program if no user_format is set. This is because instead of checking for the pointer value it checks for its dereferenced value, this being NULL if user_format is not set.
Teach the proper condition to check if user_format is set.
Signed-off-by: Mirko Faina <mroik@delayed.space> --- pretty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pretty.c b/pretty.c index e0646bbc5d..cdb8bf559d 100644 --- a/pretty.c +++ b/pretty.c @@ -47,7 +47,7 @@ static struct cmt_fmt_map *find_commit_format(const char *sought); int commit_format_is_empty(enum cmit_fmt fmt) { - return fmt == CMIT_FMT_USERFORMAT && !*user_format; + return fmt == CMIT_FMT_USERFORMAT && !user_format; } static void save_user_format(struct rev_info *rev, const char *cp, int is_tformat)
-- 2.53.0.4.geaa3cc5f7e