mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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.
This commit is contained in:
parent
7963421dd2
commit
afaec37037
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user