diff options
author | Anthony Ramine <[email protected]> | 2014-03-04 02:08:06 +0100 |
---|---|---|
committer | Anthony Ramine <[email protected]> | 2014-03-04 02:08:06 +0100 |
commit | d5fc107d5ae384bfb7b7ea1a10291b75d821c666 (patch) | |
tree | d828cfb90dec8bfcb63dddd88a1c510d0b9f3954 /lib/compiler/src | |
parent | a74e66a68f3b4ed590f928b4fd4f0808c6287a32 (diff) | |
download | otp-d5fc107d5ae384bfb7b7ea1a10291b75d821c666.tar.gz otp-d5fc107d5ae384bfb7b7ea1a10291b75d821c666.tar.bz2 otp-d5fc107d5ae384bfb7b7ea1a10291b75d821c666.zip |
Properly detect nonboolean protected expressions in beam_bool
Silly code such as the following could make the compiler crash:
f() when erlang:float(self()); true -> ok.
Reported-by: Ulf Norell
Diffstat (limited to 'lib/compiler/src')
-rw-r--r-- | lib/compiler/src/beam_bool.erl | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/compiler/src/beam_bool.erl b/lib/compiler/src/beam_bool.erl index 124abd13c1..890fbfbf4b 100644 --- a/lib/compiler/src/beam_bool.erl +++ b/lib/compiler/src/beam_bool.erl @@ -391,10 +391,14 @@ bopt_tree([{set,_,_,{bif,'xor',_}}|_], _, _) -> throw('xor'); bopt_tree([{protected,[Dst],Code,_}|Is], Forest0, Pre) -> ProtForest0 = gb_trees:from_orddict([P || {_,any}=P <- gb_trees:to_list(Forest0)]), - {ProtPre,[{_,ProtTree}]} = bopt_tree(Code, ProtForest0, []), - Prot = {prot,ProtPre,ProtTree}, - Forest = gb_trees:enter(Dst, Prot, Forest0), - bopt_tree(Is, Forest, Pre); + case bopt_tree(Code, ProtForest0, []) of + {ProtPre,[{_,ProtTree}]} -> + Prot = {prot,ProtPre,ProtTree}, + Forest = gb_trees:enter(Dst, Prot, Forest0), + bopt_tree(Is, Forest, Pre); + _Res -> + throw(not_boolean_expr) + end; bopt_tree([{set,[Dst],[Src],move}=Move|Is], Forest, Pre) -> case {Src,Dst} of {{tmp,_},_} -> throw(move); |