File 4061-v3_core-Stricten-tests-for-integers.patch of Package erlang

From 2c10759484c7e304e616ec02cc157f1d9d3669d2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Thu, 30 Jun 2022 05:17:07 +0200
Subject: [PATCH 1/6] v3_core: Stricten tests for integers

---
 lib/compiler/src/v3_core.erl | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl
index 974d3413b1..34959a5834 100644
--- a/lib/compiler/src/v3_core.erl
+++ b/lib/compiler/src/v3_core.erl
@@ -236,7 +236,8 @@ defined_functions(Forms) ->
 %%     io:format("~w/~w " ++ Format,[Name,Arity]++Terms),
 %%     ok.
 
-function({function,_,Name,Arity,Cs0}, Ws0, File, Opts) ->
+function({function,_,Name,Arity,Cs0}, Ws0, File, Opts)
+  when is_integer(Arity), 0 =< Arity, Arity =< 255 ->
     St0 = #core{vcount=0,opts=Opts,ws=Ws0,file=[{file,File}]},
     {B0,St1} = body(Cs0, Name, Arity, St0),
     %% ok = function_dump(Name,Arity,"body:~n~p~n",[B0]),
@@ -1516,7 +1517,7 @@ verify_suitable_fields([]) -> ok.
 %% Count the number of bits approximately needed to store Int.
 %% (We don't need an exact result for this purpose.)
 
-count_bits(Int) -> 
+count_bits(Int) when is_integer(Int) ->
     count_bits_1(abs(Int), 64).
 
 count_bits_1(0, Bits) -> Bits;
@@ -1886,12 +1886,12 @@ make_vars(Vs) -> [ #c_var{name=V} || V <- Vs ].
 
 %% new_fun_name(Type, State) -> {FunName,State}.
 
-new_fun_name(Type, #core{fcount=C}=St) ->
+new_fun_name(Type, #core{fcount=C}=St) when is_integer(C) ->
     {list_to_atom(Type ++ "$^" ++ integer_to_list(C)),St#core{fcount=C+1}}.
 
 %% new_var_name(State) -> {VarName,State}.
 
-new_var_name(#core{vcount=C}=St) ->
+new_var_name(#core{vcount=C}=St) when is_integer(C) ->
     {list_to_atom("cor" ++ integer_to_list(C)),St#core{vcount=C + 1}}.
 
 %% new_var(State) -> {{var,Name},State}.
-- 
2.35.3

openSUSE Build Service is sponsored by