Check if RoundingDecimals is nil before loading

This prevents the nil pointer dereference panic occuring when not set it is not set.
This commit is contained in:
ionutboangiu
2023-05-22 03:33:22 -04:00
committed by Dan Christian Bogos
parent a2633a7fd7
commit e06fc9eb8d

View File

@@ -197,8 +197,10 @@ func (fc *FCTemplate) Clone() *FCTemplate {
cln.BreakOnSuccess = fc.BreakOnSuccess
cln.Layout = fc.Layout
cln.CostShiftDigits = fc.CostShiftDigits
cln.RoundingDecimals = new(int)
*cln.RoundingDecimals = *fc.RoundingDecimals
if fc.RoundingDecimals != nil {
cln.RoundingDecimals = new(int)
*cln.RoundingDecimals = *fc.RoundingDecimals
}
cln.MaskDestID = fc.MaskDestID
cln.MaskLen = fc.MaskLen
return cln