Skip to content

Commit

Permalink
Bug 672760 - Postponed transaction applied invalid date
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jralls committed Jan 13, 2015
1 parent 7963421 commit afaec37
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/app-utils/gnc-sx-instance-model.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions src/engine/SchedXaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit afaec37

Please sign in to comment.