aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorKjell Winblad <[email protected]>2019-02-14 15:37:43 +0100
committerKjell Winblad <[email protected]>2019-02-14 15:37:43 +0100
commit11d4a893e50b1738b01846a5e669addb3e5a4f75 (patch)
tree96ce943ff5d991ef94be255e11aeb2ab78e9eb5b /erts
parent5da74b88496c9231d2fbd9cb2b7aea1121b79fa0 (diff)
parentacf97f8bcb4846bdc5935770b22ce1cb84a90a15 (diff)
downloadotp-11d4a893e50b1738b01846a5e669addb3e5a4f75.tar.gz
otp-11d4a893e50b1738b01846a5e669addb3e5a4f75.tar.bz2
otp-11d4a893e50b1738b01846a5e669addb3e5a4f75.zip
Merge branch 'maint'
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/erl_bif_binary.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/erts/emulator/beam/erl_bif_binary.c b/erts/emulator/beam/erl_bif_binary.c
index ca1ba55b22..4d6d31cd76 100644
--- a/erts/emulator/beam/erl_bif_binary.c
+++ b/erts/emulator/beam/erl_bif_binary.c
@@ -2735,7 +2735,7 @@ static BIF_RETTYPE do_encode_unsigned(Process *p, Eterm uns, Eterm endianess)
dsize_t num_parts = BIG_SIZE(bigp);
Eterm res;
byte *b;
- ErtsDigit d;
+ ErtsDigit d = 0;
if(BIG_SIGN(bigp)) {
goto badarg;
@@ -2751,26 +2751,22 @@ static BIF_RETTYPE do_encode_unsigned(Process *p, Eterm uns, Eterm endianess)
if (endianess == am_big) {
Sint i,j;
j = 0;
- d = BIG_DIGIT(bigp,0);
for (i=n-1;i>=0;--i) {
- b[i] = d & 0xFF;
- if (!((++j) % sizeof(ErtsDigit))) {
+ if (!((j++) % sizeof(ErtsDigit))) {
d = BIG_DIGIT(bigp,j / sizeof(ErtsDigit));
- } else {
- d >>= 8;
}
+ b[i] = d & 0xFF;
+ d >>= 8;
}
} else {
Sint i,j;
j = 0;
- d = BIG_DIGIT(bigp,0);
for (i=0;i<n;++i) {
- b[i] = d & 0xFF;
- if (!((++j) % sizeof(ErtsDigit))) {
+ if (!((j++) % sizeof(ErtsDigit))) {
d = BIG_DIGIT(bigp,j / sizeof(ErtsDigit));
- } else {
- d >>= 8;
}
+ b[i] = d & 0xFF;
+ d >>= 8;
}
}