File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -111,7 +111,10 @@ but small numbers can only be represented with limited exactness (one digit
111111GS_DECLARE void
112112NSDecimalCopy (NSDecimal *destination, const NSDecimal *source)
113113{
114- memcpy (destination, source, sizeof (NSDecimal ));
114+ if (destination != source)
115+ {
116+ memcpy (destination, source, sizeof (NSDecimal ));
117+ }
115118}
116119
117120static void
@@ -1566,7 +1569,7 @@ static void DecimalToCharvec(const NSDecimal *n, GSDecimal *m)
15661569 else
15671570 carry = 0 ;
15681571 // This is one off to allow final carry
1569- n.cMantissa [j+1 ] = e;
1572+ if (j < l-> length - 1 ) n.cMantissa [j+1 ] = e;
15701573 }
15711574 n.cMantissa [0 ] = carry;
15721575 NSDecimalCompact (&n);
@@ -1654,7 +1657,7 @@ static void DecimalToCharvec(const NSDecimal *n, GSDecimal *m)
16541657 error1 = NSDecimalSubtract (&n1, &n1, r, mode);
16551658 if (NSCalculationNoError != error1)
16561659 error = error1;
1657- result->cMantissa [k-1 ]++;
1660+ if (k > 0 ) result->cMantissa [k-1 ]++;
16581661 }
16591662
16601663 return error;
You can’t perform that action at this time.
0 commit comments