Bug in erl_interface in R9C?

Javier París Fernández paris@REDACTED
Wed Aug 20 18:55:02 CEST 2003


Hi,

I think there's a bug in ei_decode_longlong when decoding integers bigger
than 2^32.

--- otp_src_R9C-0/lib/erl_interface/src/decode/decode_longlong.c~       2003-08-20 18:01:54.000000000 +0200
+++ otp_src_R9C-0/lib/erl_interface/src/decode/decode_longlong.c        2003-08-20 18:19:18.000000000 +0200
@@ -51,7 +51,7 @@
        int pos, shift = 0;
        n = 0;
        for (pos = 0; pos < arity; pos++) {
-           n |= get8(s) << shift;
+           n |= ((EI_LONGLONG) get8(s)) << shift;
            shift += 8;
        }
     }

The result of get8(s) << shift is an integer, but when the shift makes the
number bigger than 2^32 the remaining bits are discarded. Putting a cast
to force the result to be 64 bits solves the problem.

Regards.




More information about the erlang-questions mailing list