mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Protect from potential nullptr dereferences.
pmtsched is created in only one banch of the opening switch. Found by clang static analyzer.
This commit is contained in:
parent
8f22c4bed4
commit
24ce92056d
@ -1969,13 +1969,16 @@ Amortization_Schedule (amort_sched_ptr amortsched)
|
||||
/* and set remaining pv to fv */
|
||||
pv = fv;
|
||||
|
||||
pmtsched->period_num = s++;
|
||||
pmtsched->interest = pmt_int;
|
||||
pmtsched->principal = prin;
|
||||
pmtsched->advanced_pmt = adv_pmt;
|
||||
pmtsched->total_pmt = final_pmt;
|
||||
pmtsched->balance = pv;
|
||||
|
||||
if (pmtsched)
|
||||
{
|
||||
pmtsched->period_num = s++;
|
||||
pmtsched->interest = pmt_int;
|
||||
pmtsched->principal = prin;
|
||||
pmtsched->advanced_pmt = adv_pmt;
|
||||
pmtsched->total_pmt = final_pmt;
|
||||
pmtsched->balance = pv;
|
||||
}
|
||||
|
||||
per_cnt++;
|
||||
pmt_cnt++;
|
||||
} /* endif */
|
||||
@ -2111,13 +2114,16 @@ Amortization_Schedule (amort_sched_ptr amortsched)
|
||||
/* # and set remaining pv to fv */
|
||||
pv = fv;
|
||||
|
||||
pmtsched->period_num = s++;
|
||||
pmtsched->interest = pmt_int;
|
||||
pmtsched->principal = prin;
|
||||
pmtsched->advanced_pmt = adv_pmt;
|
||||
pmtsched->total_pmt = final_pmt;
|
||||
pmtsched->balance = pv;
|
||||
|
||||
if (pmtsched)
|
||||
{
|
||||
pmtsched->period_num = s++;
|
||||
pmtsched->interest = pmt_int;
|
||||
pmtsched->principal = prin;
|
||||
pmtsched->advanced_pmt = adv_pmt;
|
||||
pmtsched->total_pmt = final_pmt;
|
||||
pmtsched->balance = pv;
|
||||
}
|
||||
|
||||
per_cnt++;
|
||||
pmt_cnt++;
|
||||
} /* # endif */
|
||||
@ -2199,12 +2205,14 @@ Amortization_Schedule (amort_sched_ptr amortsched)
|
||||
|
||||
/* sum total interest paid */
|
||||
sum_int += pmt_int;
|
||||
|
||||
pmtsched->period_num = s++;
|
||||
pmtsched->interest = -pmt_int;
|
||||
pmtsched->total_pmt = -pv + pmt_int;
|
||||
pmtsched->balance = 0.0;
|
||||
|
||||
if (pmtsched)
|
||||
{
|
||||
pmtsched->period_num = s++;
|
||||
pmtsched->interest = -pmt_int;
|
||||
pmtsched->total_pmt = -pv + pmt_int;
|
||||
pmtsched->balance = 0.0;
|
||||
}
|
||||
|
||||
amortyr->final_pmt = -pv - pmt_int;
|
||||
} /* endif */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user