mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Avoid a crash when entering invalid dates (e.g., enter "111" for a transaction date).
gnc_parse_date is ignoring the return code from qof_scan_date which causes it to send uninitialized values to gnc_mktime which crashes if the date is too ridiculous. Presumably this worked before because mktime took anything without crashing. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22755 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
c295ef3d28
commit
9ba6e69d5e
@ -100,7 +100,15 @@ gnc_parse_date (struct tm *parsed, const char * datestr)
|
||||
if (!parsed) return;
|
||||
if (!datestr) return;
|
||||
|
||||
qof_scan_date (datestr, &day, &month, &year);
|
||||
if (!qof_scan_date (datestr, &day, &month, &year))
|
||||
{
|
||||
// Couldn't parse date, use today
|
||||
struct tm tm_today;
|
||||
gnc_tm_get_today_start (&tm_today);
|
||||
day = tm_today.tm_mday;
|
||||
month = tm_today.tm_mon + 1;
|
||||
year = tm_today.tm_year + 1900;
|
||||
}
|
||||
|
||||
// If we have an auto-read-only threshold, do not accept a date that is
|
||||
// older than the threshold.
|
||||
|
Loading…
Reference in New Issue
Block a user