File 0387-beam_validator-Raise-an-error-on-invalid-register-us.patch of Package erlang

From c2df1a6da226de7cb83e28529616135f84f729da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org>
Date: Wed, 4 Mar 2020 11:36:47 +0100
Subject: [PATCH] beam_validator: Raise an error on invalid register use

This is a pinch better than crashing outright.
---
 lib/compiler/src/beam_validator.erl | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl
index 13145327ee..71f87e14b2 100644
--- a/lib/compiler/src/beam_validator.erl
+++ b/lib/compiler/src/beam_validator.erl
@@ -2111,7 +2111,9 @@ set_reg_vref(Ref, {y,_}=Dst, #vst{current=#st{ys=Ys0}=St0} = Vst) ->
             %% Storing into a non-existent Y register means that we haven't set
             %% up a (sufficiently large) stack.
             error({invalid_store, Dst})
-    end.
+    end;
+set_reg_vref(_Ref, Dst, _Vst) ->
+    error({invalid_register, Dst}).
 
 get_reg_vref({x,_}=Src, #vst{current=#st{xs=Xs}}) ->
     check_limit(Src),
@@ -2132,7 +2134,9 @@ get_reg_vref({y,_}=Src, #vst{current=#st{ys=Ys}}) ->
             error(Tag);
         #{} ->
             error({uninitialized_reg, Src})
-    end.
+    end;
+get_reg_vref(Src, _Vst) ->
+    error({invalid_register, Src}).
 
 set_type(Type, #value_ref{}=Ref, #vst{current=#st{vs=Vs0}=St}=Vst) ->
     #{ Ref := #value{}=Entry } = Vs0,
-- 
2.16.4

openSUSE Build Service is sponsored by