aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/v3_core.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2012-08-23 09:58:17 +0200
committerBjörn Gustavsson <[email protected]>2012-08-23 09:58:17 +0200
commite7720fe2b2a1f09af70e74b54442f72f84609a31 (patch)
treed4fc0f35f41d9c9e1674af29510e797a118220fc /lib/compiler/src/v3_core.erl
parente479ebeb58beaa8261fa90e54681dc30e5ee3085 (diff)
parente4e5d08621137473674cf3cdce0b36a43a8d6d15 (diff)
downloadotp-e7720fe2b2a1f09af70e74b54442f72f84609a31.tar.gz
otp-e7720fe2b2a1f09af70e74b54442f72f84609a31.tar.bz2
otp-e7720fe2b2a1f09af70e74b54442f72f84609a31.zip
Merge branch 'bjorn/compiler/illegal-size/OTP-10197' into maint
* bjorn/compiler/illegal-size/OTP-10197: compiler: Warn if the size of a binary segment is invalid
Diffstat (limited to 'lib/compiler/src/v3_core.erl')
-rw-r--r--lib/compiler/src/v3_core.erl7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl
index 242196c593..01042cc56f 100644
--- a/lib/compiler/src/v3_core.erl
+++ b/lib/compiler/src/v3_core.erl
@@ -823,6 +823,13 @@ bitstr({bin_element,_,E0,Size0,[Type,{unit,Unit}|Flags]}, St0) ->
{_,_} ->
throw(bad_binary)
end,
+ case Size1 of
+ #c_var{} -> ok;
+ #c_literal{val=Sz} when is_integer(Sz), Sz >= 0 -> ok;
+ #c_literal{val=undefined} -> ok;
+ #c_literal{val=all} -> ok;
+ _ -> throw(bad_binary)
+ end,
{#c_bitstr{val=E1,size=Size1,
unit=#c_literal{val=Unit},
type=#c_literal{val=Type},