This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
utf8.c: Add assertion
authorKarl Williamson <public@khwilliamson.com>
Sun, 6 May 2012 15:12:19 +0000 (09:12 -0600)
committerKarl Williamson <public@khwilliamson.com>
Tue, 22 May 2012 14:24:21 +0000 (08:24 -0600)
utf8.c

diff --git a/utf8.c b/utf8.c
index dfebf72..29b30cf 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -2707,6 +2707,8 @@ Perl__to_utf8_fold_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, U8 flags, b
 
     PERL_ARGS_ASSERT__TO_UTF8_FOLD_FLAGS;
 
 
     PERL_ARGS_ASSERT__TO_UTF8_FOLD_FLAGS;
 
+    assert(p != ustrp); /* Otherwise overwrites */
+
     if (UTF8_IS_INVARIANT(*p)) {
        if (flags & FOLD_FLAGS_LOCALE) {
            result = toLOWER_LC(*p);
     if (UTF8_IS_INVARIANT(*p)) {
        if (flags & FOLD_FLAGS_LOCALE) {
            result = toLOWER_LC(*p);