This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid a panic from the UTF-8 length cache if the length overflows 32 bits.
authorNicholas Clark <nick@ccl4.org>
Thu, 18 Feb 2010 15:38:11 +0000 (15:38 +0000)
committerNicholas Clark <nick@ccl4.org>
Thu, 18 Feb 2010 15:52:10 +0000 (15:52 +0000)
Rather than storing a value, and having it wrap to a wrong value, treat such
lengths as "still unknown". This is a work around until a proper solution is
designed an implemented.

sv.c

diff --git a/sv.c b/sv.c
index 40c95d5..53e3410 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -6072,6 +6072,10 @@ Perl_sv_len_utf8(pTHX_ register SV *const sv)
                    }
                    assert(mg);
                    mg->mg_len = ulen;
+                   /* For now, treat "overflowed" as "still unknown".
+                      See RT #72924.  */
+                   if (ulen != (STRLEN) mg->mg_len)
+                       mg->mg_len = -1;
                }
            }
            return ulen;