|
|
b8876f |
From 08bc282a248b21c92ff45e49490fb95e24358213 Mon Sep 17 00:00:00 2001
|
|
|
b8876f |
From: David Mitchell <davem@iabyn.com>
|
|
|
b8876f |
Date: Tue, 9 May 2017 14:29:11 +0100
|
|
|
b8876f |
Subject: [PATCH] sprintf(): add memory wrap tests
|
|
|
b8876f |
MIME-Version: 1.0
|
|
|
b8876f |
Content-Type: text/plain; charset=UTF-8
|
|
|
b8876f |
Content-Transfer-Encoding: 8bit
|
|
|
b8876f |
|
|
|
b8876f |
Ported to 5.24.1:
|
|
|
b8876f |
|
|
|
b8876f |
commit d729f63cc94318c248eab95844cfbed5298a7ecd
|
|
|
b8876f |
Author: David Mitchell <davem@iabyn.com>
|
|
|
b8876f |
Date: Tue May 9 14:29:11 2017 +0100
|
|
|
b8876f |
|
|
|
b8876f |
sprintf(): add memory wrap tests
|
|
|
b8876f |
|
|
|
b8876f |
In various places Perl_sv_vcatpvfn_flags() does croak_memory_wrap()
|
|
|
b8876f |
(including a couple added by the previous commit to fix RT #131260),
|
|
|
b8876f |
but there don't appear to be any tests for them.
|
|
|
b8876f |
|
|
|
b8876f |
So this commit adds some tests.
|
|
|
b8876f |
|
|
|
b8876f |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
b8876f |
---
|
|
|
b8876f |
t/op/sprintf2.t | 29 ++++++++++++++++++++++++++++-
|
|
|
b8876f |
1 file changed, 28 insertions(+), 1 deletion(-)
|
|
|
b8876f |
|
|
|
b8876f |
diff --git a/t/op/sprintf2.t b/t/op/sprintf2.t
|
|
|
b8876f |
index 43ed919..ef8a743 100644
|
|
|
b8876f |
--- a/t/op/sprintf2.t
|
|
|
b8876f |
+++ b/t/op/sprintf2.t
|
|
|
b8876f |
@@ -749,6 +749,33 @@ SKIP: {
|
|
|
b8876f |
"non-canonical form");
|
|
|
b8876f |
}
|
|
|
b8876f |
}
|
|
|
b8876f |
+
|
|
|
b8876f |
+# check all calls to croak_memory_wrap()
|
|
|
b8876f |
+# RT #131260
|
|
|
b8876f |
+
|
|
|
b8876f |
+{
|
|
|
b8876f |
+ my $s = 8 * $Config{sizesize};
|
|
|
b8876f |
+ my $i = 1;
|
|
|
b8876f |
+ my $max;
|
|
|
b8876f |
+ while ($s--) { $max |= $i; $i <<= 1; }
|
|
|
b8876f |
+ my $max40 = $max - 40; # see the magic fudge factor in sv_vcatpvfn_flags()
|
|
|
b8876f |
+
|
|
|
b8876f |
+ my @tests = (
|
|
|
b8876f |
+ # format, arg
|
|
|
b8876f |
+ ["%.${max}a", 1.1 ],
|
|
|
b8876f |
+ ["%.${max40}a", 1.1 ],
|
|
|
b8876f |
+ ["%.${max}i", 1 ],
|
|
|
b8876f |
+ ["%.${max}i", -1 ],
|
|
|
b8876f |
+ );
|
|
|
b8876f |
+
|
|
|
b8876f |
+ for my $test (@tests) {
|
|
|
b8876f |
+ my ($fmt, $arg) = @$test;
|
|
|
b8876f |
+ eval { my $s = sprintf $fmt, $arg; };
|
|
|
b8876f |
+ like("$@", qr/panic: memory wrap/, qq{memory wrap: "$fmt", "$arg"});
|
|
|
b8876f |
+ }
|
|
|
b8876f |
+}
|
|
|
b8876f |
+
|
|
|
b8876f |
+
|
|
|
b8876f |
|
|
|
b8876f |
# These are IEEE 754 64-bit subnormals (formerly known as denormals).
|
|
|
b8876f |
# Keep these as strings so that non-IEEE-754 don't trip over them.
|
|
|
b8876f |
--
|
|
|
b8876f |
2.9.4
|
|
|
b8876f |
|