File 0196-core_parse-Fix-handling-of-negative-sizes-in-binarie.patch of Package erlang
From 4332bcdc9f6dd1b4c390a50df07b7e8ebf536f88 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Mon, 19 Mar 2018 14:40:32 +0100
Subject: [PATCH 1/2] core_parse: Fix handling of negative sizes in binaries
A literal negative size in binary construction would cause a crash.
---
lib/compiler/src/core_parse.yrl | 2 +-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/compiler/src/core_parse.yrl b/lib/compiler/src/core_parse.yrl
index 79a7cccd98..85444023c6 100644
--- a/lib/compiler/src/core_parse.yrl
+++ b/lib/compiler/src/core_parse.yrl
@@ -496,7 +496,7 @@ make_lit_bin(Acc, [#c_bitstr{val=I0,size=Sz0,unit=U0,type=Type0,flags=F0}|T]) ->
throw(impossible)
end,
if
- Sz =< 8, T =:= [] ->
+ 0 =< Sz, Sz =< 8, T =:= [] ->
<<Acc/binary,I:Sz>>;
Sz =:= 8 ->
make_lit_bin(<<Acc/binary,I:8>>, T);
--
2.16.3