Fix a simple bug in the decNumberSetBCD() function. This function
encodes a decNumber with "n" BCD digits. The original code erroneously
computed the number of declets from the dn argument, which is the output
decNumber value, and hence may contain garbage. Instead, the input "n"
value is used.
Signed-off-by: Tom Musta <[email protected]>
Signed-off-by: Alexander Graf <[email protected]>
/* and bcd[0] zero. */
/* ------------------------------------------------------------------ */
decNumber * decNumberSetBCD(decNumber *dn, const uByte *bcd, uInt n) {
- Unit *up=dn->lsu+D2U(dn->digits)-1; /* -> msu [target pointer] */
+ Unit *up = dn->lsu + D2U(n) - 1; /* -> msu [target pointer] */
const uByte *ub=bcd; /* -> source msd */
#if DECDPUN==1 /* trivial simple copy */