aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorMike Sassak <[email protected]>2013-09-13 16:37:50 -0700
committerMike Sassak <[email protected]>2013-09-20 19:22:59 -0700
commit17f6fd613e8b7039526fbb063c6751fc0c2008c3 (patch)
treee942e9547298ff895b8b6d4aaf74bbe3dee1f4c9 /erts
parent589a9ed126d205007e79c22053d1b156a383d99f (diff)
downloadotp-17f6fd613e8b7039526fbb063c6751fc0c2008c3.tar.gz
otp-17f6fd613e8b7039526fbb063c6751fc0c2008c3.tar.bz2
otp-17f6fd613e8b7039526fbb063c6751fc0c2008c3.zip
Check all pattern arguments passed to binary:matches/2
Including an empty binary as one of multiple patterns passed to binary:matches/2 would crash BEAM with: "Cannot reallocate 1342177280 bytes of memory (of type "tmp")". This ensures each pattern is valid before trying to match.
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/erl_bif_binary.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_bif_binary.c b/erts/emulator/beam/erl_bif_binary.c
index 0db19a1ee6..ff775691b3 100644
--- a/erts/emulator/beam/erl_bif_binary.c
+++ b/erts/emulator/beam/erl_bif_binary.c
@@ -927,6 +927,9 @@ static int do_binary_match_compile(Eterm argument, Eterm *tag, Binary **binp)
if (binary_bitsize(b) != 0) {
goto badarg;
}
+ if (binary_size(b) == 0) {
+ goto badarg;
+ }
++words;
characters += binary_size(b);
}