aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test
diff options
context:
space:
mode:
authorKjell Winblad <[email protected]>2019-02-14 15:32:06 +0100
committerGitHub <[email protected]>2019-02-14 15:32:06 +0100
commitacf97f8bcb4846bdc5935770b22ce1cb84a90a15 (patch)
tree579a2f1e8754130aaa59c636ce2e4335a73d0746 /lib/stdlib/test
parentf45efdd2663b8050edb4351a8d1d57d437fb6e51 (diff)
parent1df3d85824601e3c07d12ca9811866c2ef334e76 (diff)
downloadotp-acf97f8bcb4846bdc5935770b22ce1cb84a90a15.tar.gz
otp-acf97f8bcb4846bdc5935770b22ce1cb84a90a15.tar.bz2
otp-acf97f8bcb4846bdc5935770b22ce1cb84a90a15.zip
Merge pull request #2118 from kjellwinblad/fix_valgrind_problem_bignum OTP-15583
Fix bug in binary:encode_unsigned causing a read of uninitialized memory
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r--lib/stdlib/test/binary_module_SUITE.erl15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/stdlib/test/binary_module_SUITE.erl b/lib/stdlib/test/binary_module_SUITE.erl
index c5cfea5e9e..e0811f19cf 100644
--- a/lib/stdlib/test/binary_module_SUITE.erl
+++ b/lib/stdlib/test/binary_module_SUITE.erl
@@ -22,7 +22,8 @@
-export([all/0, suite/0,
interesting/1,scope_return/1,random_ref_comp/1,random_ref_sr_comp/1,
random_ref_fla_comp/1,parts/1, bin_to_list/1, list_to_bin/1,
- copy/1, referenced/1,guard/1,encode_decode/1,badargs/1,longest_common_trap/1]).
+ copy/1, referenced/1,guard/1,encode_decode/1,badargs/1,longest_common_trap/1,
+ check_no_invalid_read_bug/1]).
-export([random_number/1, make_unaligned/1]).
@@ -36,7 +37,7 @@ all() ->
[scope_return,interesting, random_ref_fla_comp, random_ref_sr_comp,
random_ref_comp, parts, bin_to_list, list_to_bin, copy,
referenced, guard, encode_decode, badargs,
- longest_common_trap].
+ longest_common_trap, check_no_invalid_read_bug].
-define(MASK_ERROR(EXPR),mask_error((catch (EXPR)))).
@@ -1361,3 +1362,13 @@ make_unaligned2(Bin0) when is_binary(Bin0) ->
Bin.
id(I) -> I.
+
+check_no_invalid_read_bug(Config) when is_list(Config) ->
+ check_no_invalid_read_bug(24);
+check_no_invalid_read_bug(60) ->
+ ok;
+check_no_invalid_read_bug(I) ->
+ N = 1 bsl I,
+ binary:encode_unsigned(N+N),
+ binary:encode_unsigned(N+N, little),
+ check_no_invalid_read_bug(I+1).