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.
This commit is contained in:
Patric Mueller
2024-03-03 16:14:15 +01:00
parent 53778ee507
commit fb353fff6c
+2
View File
@@ -1235,6 +1235,7 @@ optfn_crash_email(int optidx UNUSED, int req, boolean negated UNUSED, char *opts
if (req == get_val || req == get_cnf_val) { if (req == get_val || req == get_cnf_val) {
if (!opts) if (!opts)
return optn_err; return optn_err;
if (gc.crash_email)
Sprintf(opts, "%s", gc.crash_email); Sprintf(opts, "%s", gc.crash_email);
return optn_ok; return optn_ok;
} }
@@ -1258,6 +1259,7 @@ optfn_crash_name(int optidx UNUSED, int req, boolean negated UNUSED, char *opts,
if (req == get_val || req == get_cnf_val) { if (req == get_val || req == get_cnf_val) {
if (!opts) if (!opts)
return optn_err; return optn_err;
if (gc.crash_name)
Sprintf(opts, "%s", gc.crash_name); Sprintf(opts, "%s", gc.crash_name);
return optn_ok; return optn_ok;
} }