From eaeea8dbde10e5e0a1c65bfd093ae18398b400d0 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Thu, 1 Aug 2013 02:03:39 +0200 Subject: Forbid returning a match context in beam_validator If a match context is returned from a function without being converted back to a plain old binary, the whole VM will crash. --- lib/compiler/src/beam_validator.erl | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/compiler/src/beam_validator.erl') diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl index eb72290306..70279ab658 100644 --- a/lib/compiler/src/beam_validator.erl +++ b/lib/compiler/src/beam_validator.erl @@ -628,6 +628,7 @@ valfun_4({gc_bif,Op,{f,Fail},Live,Src,Dst}, #vst{current=St0}=Vst0) -> Type = bif_type(Op, Src, Vst), set_type_reg(Type, Dst, Vst); valfun_4(return, #vst{current=#st{numy=none}}=Vst) -> + assert_term({x,0}, Vst), kill_state(Vst); valfun_4(return, #vst{current=#st{numy=NumY}}) -> error({stack_frame,NumY}); -- cgit v1.2.3