mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Protect GDateTime from getting an out-of-range year at creation.
It can behave badly. See https://bugzilla.gnome.org/show_bug.cgi?id=721791#c8 git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23725 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
bcd5543195
commit
4efb4cd8c3
@ -301,6 +301,7 @@ gnc_tm_free (struct tm* time)
|
||||
static void
|
||||
gnc_g_date_time_fill_struct_tm (GDateTime *gdt, struct tm* time)
|
||||
{
|
||||
memset (time, 0, sizeof (struct tm));
|
||||
g_date_time_get_ymd (gdt, &(time->tm_year), &(time->tm_mon), &(time->tm_mday));
|
||||
time->tm_sec = g_date_time_get_second (gdt);
|
||||
time->tm_min = g_date_time_get_minute (gdt);
|
||||
@ -394,6 +395,11 @@ normalize_struct_tm (struct tm* time)
|
||||
time64 secs;
|
||||
|
||||
++time->tm_mon;
|
||||
/* GDateTime doesn't protect itself against out-of range years,
|
||||
* so clamp year into GDateTime's range.
|
||||
*/
|
||||
if (year < 0) year = -year;
|
||||
if (year > 9999) year % 10000;
|
||||
|
||||
normalize_time_component (&(time->tm_sec), &(time->tm_min), 60, 0);
|
||||
normalize_time_component (&(time->tm_min), &(time->tm_hour), 60, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user