]> Git Repo - qemu.git/commitdiff
libdecnumber: Fix decNumberSetBCD
authorTom Musta <[email protected]>
Mon, 21 Apr 2014 20:54:55 +0000 (15:54 -0500)
committerAlexander Graf <[email protected]>
Mon, 16 Jun 2014 11:24:29 +0000 (13:24 +0200)
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]>
libdecnumber/decNumber.c

index 6164a775092fde4ecabf66e3d3e50b2642063691..a30632f94ec213a9d72ee3ca62eb46677e41fc3e 100644 (file)
@@ -3541,7 +3541,7 @@ uByte * decNumberGetBCD(const decNumber *dn, uint8_t *bcd) {
 /* 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 */
This page took 0.037308 seconds and 4 git commands to generate.