r22122 - gnucash/trunk/src - Fix segfault after behaviour change of qof_book_get_autoreadonly_gdate() in r22118.

Christian Stimming cstim at code.gnucash.org
Sun Mar 25 15:13:17 EDT 2012


Author: cstim
Date: 2012-03-25 15:13:16 -0400 (Sun, 25 Mar 2012)
New Revision: 22122
Trac: http://svn.gnucash.org/trac/changeset/22122

Modified:
   gnucash/trunk/src/engine/Transaction.c
   gnucash/trunk/src/register/ledger-core/split-register-load.c
Log:
Fix segfault after behaviour change of qof_book_get_autoreadonly_gdate() in r22118.

Modified: gnucash/trunk/src/engine/Transaction.c
===================================================================
--- gnucash/trunk/src/engine/Transaction.c	2012-03-25 16:52:31 UTC (rev 22121)
+++ gnucash/trunk/src/engine/Transaction.c	2012-03-25 19:13:16 UTC (rev 22122)
@@ -1971,6 +1971,7 @@
     }
 
     threshold_date = qof_book_get_autoreadonly_gdate(book);
+    g_assert(threshold_date); // ok because we checked uses_autoreadonly before
     trans_date = xaccTransGetDatePostedGDate(trans);
 
 //    g_warning("there is auto-read-only with days=%d, trans_date_day=%d, threshold_date_day=%d",

Modified: gnucash/trunk/src/register/ledger-core/split-register-load.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-load.c	2012-03-25 16:52:31 UTC (rev 22121)
+++ gnucash/trunk/src/register/ledger-core/split-register-load.c	2012-03-25 19:13:16 UTC (rev 22122)
@@ -277,7 +277,7 @@
     int new_trans_split_row = -1;
     int new_trans_row = -1;
     int new_split_row = -1;
-    time_t present, autoreadonly_time;
+    time_t present, autoreadonly_time = 0;
 
     g_return_if_fail(reg);
     table = reg->table;
@@ -434,9 +434,11 @@
 
     /* get the current time and reset the dividing row */
     present = gnc_timet_get_today_end ();
+    if (use_autoreadonly)
     {
         GDate *d = qof_book_get_autoreadonly_gdate(gnc_get_current_book());
-        autoreadonly_time = timespecToTime_t(gdate_to_timespec(*d));
+        // "d" is NULL if use_autoreadonly is FALSE
+        autoreadonly_time = d ? timespecToTime_t(gdate_to_timespec(*d)) : 0;
         g_date_free(d);
     }
 



More information about the gnucash-changes mailing list