aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded/src/erlang.erl
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2013-10-16 16:28:21 +0200
committerSverker Eriksson <[email protected]>2013-11-18 20:19:51 +0100
commitd5b6c6f0bd96108d788cdfb9be15059125b3d87f (patch)
tree738c1ba0806110f3f4161a2366cf06592ed2eb25 /erts/preloaded/src/erlang.erl
parentf10ea68ce28e9b93ce614b5f829b1ca7f4cc753f (diff)
downloadotp-d5b6c6f0bd96108d788cdfb9be15059125b3d87f.tar.gz
otp-d5b6c6f0bd96108d788cdfb9be15059125b3d87f.tar.bz2
otp-d5b6c6f0bd96108d788cdfb9be15059125b3d87f.zip
erts: Add erlang wrappers to binary_to_term
to not expose the trapping BIF in the stacktrace when it throws badarg.
Diffstat (limited to 'erts/preloaded/src/erlang.erl')
-rw-r--r--erts/preloaded/src/erlang.erl18
1 files changed, 14 insertions, 4 deletions
diff --git a/erts/preloaded/src/erlang.erl b/erts/preloaded/src/erlang.erl
index e521c6fc3d..7b59f6c8b4 100644
--- a/erts/preloaded/src/erlang.erl
+++ b/erts/preloaded/src/erlang.erl
@@ -362,15 +362,25 @@ binary_to_list(_Binary, _Start, _Stop) ->
%% binary_to_term/1
-spec binary_to_term(Binary) -> term() when
Binary :: ext_binary().
-binary_to_term(_Binary) ->
- erlang:nif_error(undefined).
+binary_to_term(Binary) ->
+ %% This BIF may throw badarg while trapping
+ try
+ erts_internal:binary_to_term(Binary)
+ catch
+ error:Reason -> erlang:error(Reason,[Binary])
+ end.
%% binary_to_term/2
-spec binary_to_term(Binary, Opts) -> term() when
Binary :: ext_binary(),
Opts :: [safe].
-binary_to_term(_Binary, _Opts) ->
- erlang:nif_error(undefined).
+binary_to_term(Binary, Opts) ->
+ %% This BIF may throw badarg while trapping
+ try
+ erts_internal:binary_to_term(Binary,Opts)
+ catch
+ error:Reason -> erlang:error(Reason,[Binary,Opts])
+ end.
%% bit_size/1
%% Shadowed by erl_bif_types: erlang:bit_size/1