r23495 - gnucash/trunk/src/libqof/qof - Protect gnc_mktime against bad dates.

Mike Alexander mta at code.gnucash.org
Sat Dec 7 02:33:14 EST 2013


Author: mta
Date: 2013-12-07 02:33:14 -0500 (Sat, 07 Dec 2013)
New Revision: 23495
Trac: http://svn.gnucash.org/trac/changeset/23495

Modified:
   gnucash/trunk/src/libqof/qof/gnc-date.c
Log:
Protect gnc_mktime against bad dates.

Modified: gnucash/trunk/src/libqof/qof/gnc-date.c
===================================================================
--- gnucash/trunk/src/libqof/qof/gnc-date.c	2013-12-05 21:54:28 UTC (rev 23494)
+++ gnucash/trunk/src/libqof/qof/gnc-date.c	2013-12-07 07:33:14 UTC (rev 23495)
@@ -399,6 +399,11 @@
      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;



More information about the gnucash-changes mailing list