From 62587fc365bf017dca6b38abcbc6699906811763 Mon Sep 17 00:00:00 2001 From: coldWater <254244460@qq.com> Date: Mon, 17 Jun 2019 18:13:00 +0800 Subject: [PATCH] fix: Coefficient panic call Coefficient on uninitialized Decimal will panic --- decimal.go | 1 + 1 file changed, 1 insertion(+) diff --git a/decimal.go b/decimal.go index 134ece2..a29ea1a 100644 --- a/decimal.go +++ b/decimal.go @@ -657,6 +657,7 @@ func (d Decimal) Exponent() int32 { // Coefficient returns the coefficient of the decimal. It is scaled by 10^Exponent() func (d Decimal) Coefficient() *big.Int { + d.ensureInitialized() // we copy the coefficient so that mutating the result does not mutate the // Decimal. return big.NewInt(0).Set(d.value)