From fb353fff6cd6bb6e8f96f830511f90827135d48d Mon Sep 17 00:00:00 2001 From: Patric Mueller Date: Sun, 3 Mar 2024 13:07:10 +0100 Subject: [PATCH] Add NULL pointer guards for the crash reports variables Calling sprintf with NULL string for a %s format identifier seems to be undefined behavior. I got some semi persistent crashes while calling the extend options menu with mO. --- src/options.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/options.c b/src/options.c index 6cfe511bf..7c935a4c9 100644 --- a/src/options.c +++ b/src/options.c @@ -1235,7 +1235,8 @@ optfn_crash_email(int optidx UNUSED, int req, boolean negated UNUSED, char *opts if (req == get_val || req == get_cnf_val) { if (!opts) return optn_err; - Sprintf(opts, "%s", gc.crash_email); + if (gc.crash_email) + Sprintf(opts, "%s", gc.crash_email); return optn_ok; } return optn_ok; @@ -1258,7 +1259,8 @@ optfn_crash_name(int optidx UNUSED, int req, boolean negated UNUSED, char *opts, if (req == get_val || req == get_cnf_val) { if (!opts) return optn_err; - Sprintf(opts, "%s", gc.crash_name); + if (gc.crash_name) + Sprintf(opts, "%s", gc.crash_name); return optn_ok; } return optn_ok;