diff options
author | Sverker Eriksson <[email protected]> | 2011-06-30 19:36:07 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2011-06-30 19:52:08 +0200 |
commit | 1c0966044b66d20f3f6607e91076e0a61918f1a4 (patch) | |
tree | 89c8776966ed1d9bebb694b001f501306e50da48 /erts/emulator/beam/erl_nif.c | |
parent | 7092c4a41ac0d38ae457c2dc768aa542337d8b8c (diff) | |
download | otp-1c0966044b66d20f3f6607e91076e0a61918f1a4.tar.gz otp-1c0966044b66d20f3f6607e91076e0a61918f1a4.tar.bz2 otp-1c0966044b66d20f3f6607e91076e0a61918f1a4.zip |
Fix halfword bug in enif_make_int64
The bug was creating an invalid bignum instead of a small integer,
causing strange comparing behavior (=:= failed but == succeeded).
Diffstat (limited to 'erts/emulator/beam/erl_nif.c')
-rw-r--r-- | erts/emulator/beam/erl_nif.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c index 68421b4387..d9b1a8e89d 100644 --- a/erts/emulator/beam/erl_nif.c +++ b/erts/emulator/beam/erl_nif.c @@ -833,8 +833,11 @@ ERL_NIF_TERM enif_make_uint(ErlNifEnv* env, unsigned i) ERL_NIF_TERM enif_make_long(ErlNifEnv* env, long i) { + if (IS_SSMALL(i)) { + return make_small(i); + } #if SIZEOF_LONG == ERTS_SIZEOF_ETERM - return IS_SSMALL(i) ? make_small(i) : small_to_big(i, alloc_heap(env,2)); + return small_to_big(i, alloc_heap(env,2)); #elif SIZEOF_LONG == 8 ensure_heap(env,3); return erts_sint64_to_big(i, &env->hp); @@ -843,8 +846,11 @@ ERL_NIF_TERM enif_make_long(ErlNifEnv* env, long i) ERL_NIF_TERM enif_make_ulong(ErlNifEnv* env, unsigned long i) { + if (IS_USMALL(0,i)) { + return make_small(i); + } #if SIZEOF_LONG == ERTS_SIZEOF_ETERM - return IS_USMALL(0,i) ? make_small(i) : uint_to_big(i,alloc_heap(env,2)); + return uint_to_big(i,alloc_heap(env,2)); #elif SIZEOF_LONG == 8 ensure_heap(env,3); return erts_uint64_to_big(i, &env->hp); |