mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Protect gnc_mktime against bad dates.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23495 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
e4fc44dd1c
commit
bf1c6d3278
@ -399,6 +399,11 @@ gnc_mktime (struct tm* time)
|
||||
gdt = gnc_g_date_time_new_local (time->tm_year + 1900, time->tm_mon,
|
||||
time->tm_mday, time->tm_hour,
|
||||
time->tm_min, (gdouble)(time->tm_sec));
|
||||
if (gdt == NULL)
|
||||
{
|
||||
g_warning("Invalid time passed to gnc_mktime");
|
||||
return -1;
|
||||
}
|
||||
time->tm_mon = time->tm_mon > 0 ? time->tm_mon - 1 : 11;
|
||||
// Watch out: struct tm has wday=0..6 with Sunday=0, but GDateTime has wday=1..7 with Sunday=7.
|
||||
time->tm_wday = g_date_time_get_day_of_week (gdt) % 7;
|
||||
|
Loading…
Reference in New Issue
Block a user