aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_nif.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2016-02-08 15:47:49 +0100
committerSverker Eriksson <[email protected]>2016-02-08 16:11:56 +0100
commit7a319cd96f7f4869300b32442ebe892ae557f41c (patch)
tree74eac8b419d1f9de35b5deb46bdf2f4e3884df25 /erts/emulator/beam/erl_nif.c
parent14680fcc3fb9d0357fe33a94525d08896afed1c5 (diff)
downloadotp-7a319cd96f7f4869300b32442ebe892ae557f41c.tar.gz
otp-7a319cd96f7f4869300b32442ebe892ae557f41c.tar.bz2
otp-7a319cd96f7f4869300b32442ebe892ae557f41c.zip
erts: Fix error cases in enif_get_list_length
false if improper list false if length > UINT_MAX
Diffstat (limited to 'erts/emulator/beam/erl_nif.c')
-rw-r--r--erts/emulator/beam/erl_nif.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index b057ec7770..12aaf4ce53 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -911,8 +911,13 @@ int enif_get_list_cell(ErlNifEnv* env, Eterm term, Eterm* head, Eterm* tail)
int enif_get_list_length(ErlNifEnv* env, Eterm term, unsigned* len)
{
- if (is_not_list(term) && is_not_nil(term)) return 0;
- *len = erts_list_length(term);
+ Sint i;
+ Uint u;
+
+ if ((i = erts_list_length(term)) < 0) return 0;
+ u = (Uint)i;
+ if ((unsigned)u != u) return 0;
+ *len = u;
return 1;
}