In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/fa8f4f85ec35b0f047603e5b90a788571f7141bd?hp=c196824d8fc0928f1021c49e20298c197b184d9c>

- Log -----------------------------------------------------------------
commit fa8f4f85ec35b0f047603e5b90a788571f7141bd
Author: Tony Cook <[email protected]>
Date:   Mon Jan 19 13:31:26 2015 +1100

    [perl #123554] avoid a crash from SvGROW(MEM_SIZE_MAX)
-----------------------------------------------------------------------

Summary of changes:
 sv.c          | 7 +++++--
 t/op/repeat.t | 6 +++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/sv.c b/sv.c
index d86a61e..649c7e1 100644
--- a/sv.c
+++ b/sv.c
@@ -1594,8 +1594,11 @@ Perl_sv_grow(pTHX_ SV *const sv, STRLEN newlen)
      * make more strings COW-able.
      * If the new size is a big power of two, don't bother: we assume the
      * caller wanted a nice 2^N sized block and will be annoyed at getting
-     * 2^N+1 */
-    if (newlen & 0xff)
+     * 2^N+1.
+     * Only increment if the allocation isn't MEM_SIZE_MAX,
+     * otherwise it will wrap to 0.
+     */
+    if (newlen & 0xff && newlen != MEM_SIZE_MAX)
         newlen++;
 #endif
 
diff --git a/t/op/repeat.t b/t/op/repeat.t
index 8df5241..421b705 100644
--- a/t/op/repeat.t
+++ b/t/op/repeat.t
@@ -6,7 +6,7 @@ BEGIN {
 }
 
 require './test.pl';
-plan(tests => 47);
+plan(tests => 49);
 
 # compile time
 
@@ -173,3 +173,7 @@ for(($#that_array)x2) {
     $_ *= 2;
 }
 is($#that_array, 28, 'list repetition propagates lvalue cx to its lhs');
+
+# see [perl #123554]
+ok(!eval '33x~3', "eval 33x~3 should panic, not crash perl");
+like($@, qr/^panic: memory wrap/, "check it's a panic");

--
Perl5 Master Repository

Reply via email to