From abc4fd372d476821448dfb949bea4e28ab82ac26 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Wed, 12 Jul 2017 17:09:10 +0200 Subject: erts: Fix bug in bxor of a big negative number Wrong result for (X bsl WS) bxor Y. where X is any negative integer Y is any integer that does not require more words than X WS is erlang:system_info(wordsize) or larger Fix: The subtraction of 1 (for 2-complement conversion) must be carried along all the way to the last words. --- erts/emulator/beam/big.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'erts/emulator/beam') diff --git a/erts/emulator/beam/big.c b/erts/emulator/beam/big.c index d1e46e3063..323cd6c518 100644 --- a/erts/emulator/beam/big.c +++ b/erts/emulator/beam/big.c @@ -1273,8 +1273,11 @@ static dsize_t I_bxor(ErtsDigit* x, dsize_t xl, short xsgn, *r++ = ~c ^ *y++; x++; } - while(xl--) - *r++ = ~*x++; + while(xl--) { + DSUBb(*x,0,b,c); + *r++ = ~c; + x++; + } } else { ErtsDigit b1, b2; @@ -1292,7 +1295,9 @@ static dsize_t I_bxor(ErtsDigit* x, dsize_t xl, short xsgn, x++; y++; } while(xl--) { - *r++ = *x++; + DSUBb(*x,0,b1,c1); + *r++ = c1; + x++; } } } -- cgit v1.2.3