free CRASHREPORT option data

Plug a straightforward memory leak.
This commit is contained in:
PatR
2025-04-17 17:00:39 -07:00
parent 07b59e783e
commit 7c40819202
2 changed files with 16 additions and 8 deletions

View File

@@ -1238,11 +1238,11 @@ optfn_crash_email(
return optn_ok;
}
if (req == do_set) {
if ((op = string_for_opt(opts, FALSE))
!= empty_optstr) {
gc.crash_email = dupstr(op);
} else
if ((op = string_for_opt(opts, FALSE)) == empty_optstr)
return optn_err;
if (gc.crash_email)
free((genericptr_t) gc.crash_email);
gc.crash_email = dupstr(op);
return optn_ok;
}
if (req == get_val || req == get_cnf_val) {
@@ -1264,11 +1264,11 @@ optfn_crash_name(
return optn_ok;
}
if (req == do_set) {
if ((op = string_for_opt(opts, FALSE))
!= empty_optstr) {
gc.crash_name = dupstr(op);
} else
if ((op = string_for_opt(opts, FALSE)) == empty_optstr)
return optn_err;
if (gc.crash_name)
free((genericptr_t) gc.crash_name);
gc.crash_name = dupstr(op);
return optn_ok;
}
if (req == get_val || req == get_cnf_val) {
@@ -1311,6 +1311,7 @@ optfn_crash_urlmax(
}
return optn_ok;
}
#endif /* CRASHREPORT */
#ifdef CURSES_GRAPHICS

View File

@@ -143,6 +143,13 @@ sysopt_release(void)
if (sysopt.greppath)
free((genericptr_t) sysopt.greppath), sysopt.greppath = (char *) 0;
#ifdef CRASHREPORT
if (gc.crash_email)
free((genericptr_t) gc.crash_email), gc.crash_email = (char *) NULL;
if (gc.crash_name)
free((genericptr_t) gc.crash_name), gc.crash_name = (char *) NULL;
#endif
/* this one's last because it might be used in panic feedback, although
none of the preceding ones are likely to trigger a controlled panic */
if (sysopt.fmtd_wizard_list)