diff options
author | Tom Musta | 2014-04-21 22:54:55 +0200 |
---|---|---|
committer | Alexander Graf | 2014-06-16 13:24:29 +0200 |
commit | 0a322e7e7cc25267fb4f900d4bc193a134cd72fe (patch) | |
tree | 3d3042fe85e05338699183d612d1843aec1fcf4f /libdecnumber | |
parent | libdecnumber: Introduce decNumberIntegralToInt64 (diff) | |
download | qemu-0a322e7e7cc25267fb4f900d4bc193a134cd72fe.tar.gz qemu-0a322e7e7cc25267fb4f900d4bc193a134cd72fe.tar.xz qemu-0a322e7e7cc25267fb4f900d4bc193a134cd72fe.zip |
libdecnumber: Fix decNumberSetBCD
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 <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'libdecnumber')
-rw-r--r-- | libdecnumber/decNumber.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libdecnumber/decNumber.c b/libdecnumber/decNumber.c index 6164a77509..a30632f94e 100644 --- a/libdecnumber/decNumber.c +++ b/libdecnumber/decNumber.c @@ -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 */ |