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 13:07:10 +01:00
parent 53778ee507
commit fb353fff6c

View File

@@ -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;