This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
include a trailing \0 in SVs holding trie info
authorDavid Mitchell <davem@iabyn.com>
Tue, 6 Aug 2019 13:36:45 +0000 (14:36 +0100)
committerDavid Mitchell <davem@iabyn.com>
Tue, 6 Aug 2019 13:40:52 +0000 (14:40 +0100)
RT #13427

TRIE_STORE_REVCHAR() was creating SvPV()s with no trailing '\0'. This
doesn't really matter given the specialised use these are put to, but
it upset valgrind et al when perl was run with -Drv which printf("%s")'s
the contents of the string.

regcomp.c

index 370221f..1117998 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -2526,7 +2526,8 @@ is the recommended Unicode-aware way of saying
        if (UTF) {                                                         \
             SV *zlopp = newSV(UTF8_MAXBYTES);                             \
            unsigned char *flrbbbbb = (unsigned char *) SvPVX(zlopp);      \
-            unsigned const char *const kapow = uvchr_to_utf8(flrbbbbb, val); \
+            unsigned char *const kapow = uvchr_to_utf8(flrbbbbb, val);     \
+            *kapow = '\0';                                                 \
            SvCUR_set(zlopp, kapow - flrbbbbb);                            \
            SvPOK_on(zlopp);                                               \
            SvUTF8_on(zlopp);                                              \