plumb a leak with pos().
Adrian M. Enache [Mon, 8 Dec 2003 03:30:16 +0000 (03:30 +0000)]
#! perl
while (1) {
my $a = "\x{1ff}"; $a =~ /\x{1ff}/g; pos($a);
}
__END__

p4raw-id: //depot/perl@21866

sv.c

diff --git a/sv.c b/sv.c
index dc089b8..6f53c58 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -6056,7 +6056,8 @@ Perl_sv_pos_b2u(pTHX_ register SV* sv, I32* offsetp)
            assert(mg);
 
            if (!mg->mg_ptr) {
-               Newz(0, cache, PERL_MAGIC_UTF8_CACHESIZE * 2, STRLEN);
+               mg->mg_len = PERL_MAGIC_UTF8_CACHESIZE * 2;
+               Newz(0, cache, mg->mg_len, STRLEN);
                mg->mg_ptr = (char *) cache;
            }
            assert(cache);