diff options
author | Sverker Eriksson <[email protected]> | 2017-06-29 14:42:49 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2017-06-29 14:42:49 +0200 |
commit | 616a495f28783e05a95fd545c4a247f1a9177f81 (patch) | |
tree | 0e9163d36fecad3b62ecfd3290fb72e05b86ea5d /erts/emulator | |
parent | 49bcc77de63c37ac6c0de5c14c57583f78610f48 (diff) | |
parent | 86bcdcb3db79ac2d1faa387bbe194924e966dd69 (diff) | |
download | otp-616a495f28783e05a95fd545c4a247f1a9177f81.tar.gz otp-616a495f28783e05a95fd545c4a247f1a9177f81.tar.bz2 otp-616a495f28783e05a95fd545c4a247f1a9177f81.zip |
Merge branch 'sverker/erts/apply-badarg/ERL-432/OTP-14490' into maint
* sverker/erts/apply-badarg/ERL-432/OTP-14490:
erts: Make apply throw 'badarg' if Args is not a list
Diffstat (limited to 'erts/emulator')
-rw-r--r-- | erts/emulator/beam/beam_emu.c | 2 | ||||
-rw-r--r-- | erts/emulator/test/fun_SUITE.erl | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c index 79d751d13e..bc83699951 100644 --- a/erts/emulator/beam/beam_emu.c +++ b/erts/emulator/beam/beam_emu.c @@ -6829,7 +6829,7 @@ apply_fun(Process* p, Eterm fun, Eterm args, Eterm* reg) } if (is_not_nil(tmp)) { /* Must be well-formed list */ - p->freason = EXC_UNDEF; + p->freason = EXC_BADARG; return NULL; } reg[arity] = fun; diff --git a/erts/emulator/test/fun_SUITE.erl b/erts/emulator/test/fun_SUITE.erl index e4640909aa..7d29ebec52 100644 --- a/erts/emulator/test/fun_SUITE.erl +++ b/erts/emulator/test/fun_SUITE.erl @@ -22,6 +22,7 @@ -export([all/0, suite/0, bad_apply/1,bad_fun_call/1,badarity/1,ext_badarity/1, + bad_arglist/1, equality/1,ordering/1, fun_to_port/1,t_phash/1,t_phash2/1,md5/1, refc/1,refc_ets/1,refc_dist/1, @@ -39,6 +40,7 @@ suite() -> all() -> [bad_apply, bad_fun_call, badarity, ext_badarity, + bad_arglist, equality, ordering, fun_to_port, t_phash, t_phash2, md5, refc, refc_ets, refc_dist, const_propagation, t_arity, t_is_function2, t_fun_info, @@ -107,6 +109,18 @@ bad_call_fc(Fun) -> ct:fail({bad_result,Other}) end. +% Test erlang:apply with non-proper arg-list +bad_arglist(Config) when is_list(Config) -> + Fun = fun(A,B) -> A+B end, + {'EXIT', {badarg,_}} = (catch apply(Fun, 17)), + {'EXIT', {badarg,_}} = (catch apply(Fun, [17|18])), + {'EXIT', {badarg,_}} = (catch apply(Fun, [17,18|19])), + {'EXIT', {badarg,_}} = (catch apply(lists,seq, 17)), + {'EXIT', {badarg,_}} = (catch apply(lists,seq, [17|18])), + {'EXIT', {badarg,_}} = (catch apply(lists,seq, [17,18|19])), + ok. + + %% Call and apply valid funs with wrong number of arguments. badarity(Config) when is_list(Config) -> |