gnucash maint: Bug 672760 - Postponed transaction applied invalid date
John Ralls
jralls at code.gnucash.org
Tue Jan 13 13:47:54 EST 2015
Updated via https://github.com/Gnucash/gnucash/commit/afaec370 (commit)
from https://github.com/Gnucash/gnucash/commit/7963421d (commit)
commit afaec3703761ee2b7b5584b35d5eec36b9647559
Author: John Ralls <jralls at ceridwen.us>
Date: Sun Jan 11 13:57:32 2015 -0800
Bug 672760 - Postponed transaction applied invalid date
Part 2: GDate can represent a wider range that GDateTime, so make
sure that GDates outside of the range are clamped. The GDateTime
range is 1 - 9999 CE, more than wide enough for most purposes. GDate
can represent out to 65535CE, but the significant difference is that
a freshly-cleared GDate is 0CE, which GDateTime won't accept. That we
set to the Unix Epoch 0, 1970-Jan-1.
gnc_sx_incr_temporal_state can invalidate the gdate, so make sure that a
valid date is stored.
Adding the inst->temporal_state ptr to the sx->deferredList is wrong, it's
freed shortly after adding, causing later access to the freed ptr.
Add a clone instead.
diff --git a/src/app-utils/gnc-sx-instance-model.c b/src/app-utils/gnc-sx-instance-model.c
index 2b1a1f5..2b3975d 100644
--- a/src/app-utils/gnc-sx-instance-model.c
+++ b/src/app-utils/gnc-sx-instance-model.c
@@ -1318,7 +1318,8 @@ gnc_sx_instance_model_effect_change(GncSxInstanceModel *model,
case SX_INSTANCE_STATE_POSTPONED:
if (inst->orig_state != SX_INSTANCE_STATE_POSTPONED)
{
- gnc_sx_add_defer_instance(instances->sx, inst->temporal_state);
+ gnc_sx_add_defer_instance(instances->sx,
+ gnc_sx_clone_temporal_state (inst->temporal_state));
}
increment_sx_state(inst, &last_occur_date, &instance_count, &remain_occur_count);
break;
diff --git a/src/engine/SchedXaction.c b/src/engine/SchedXaction.c
index fddc99b..62bf445 100644
--- a/src/engine/SchedXaction.c
+++ b/src/engine/SchedXaction.c
@@ -1151,8 +1151,11 @@ SXTmpStateData*
gnc_sx_create_temporal_state(const SchedXaction *sx )
{
SXTmpStateData *toRet =
- g_new0( SXTmpStateData, 1 );
- toRet->last_date = sx->last_date;
+ g_new0( SXTmpStateData, 1 );
+ if (g_date_valid (&(sx->last_date)))
+ toRet->last_date = sx->last_date;
+ else
+ g_date_set_dmy (&(toRet->last_date), 1, 1, 1970);
toRet->num_occur_rem = sx->num_occurances_remain;
toRet->num_inst = sx->instance_num;
return toRet;
Summary of changes:
src/app-utils/gnc-sx-instance-model.c | 3 ++-
src/engine/SchedXaction.c | 7 +++++--
2 files changed, 7 insertions(+), 3 deletions(-)
More information about the gnucash-changes
mailing list