78f1eb
From 1d84a25665013f389ffc6fad7dd133f1c6287a08 Mon Sep 17 00:00:00 2001
78f1eb
From: David Mitchell <davem@iabyn.com>
78f1eb
Date: Tue, 6 Aug 2019 14:36:45 +0100
78f1eb
Subject: [PATCH] include a trailing \0 in SVs holding trie info
78f1eb
MIME-Version: 1.0
78f1eb
Content-Type: text/plain; charset=UTF-8
78f1eb
Content-Transfer-Encoding: 8bit
78f1eb
78f1eb
RT #13427
78f1eb
78f1eb
TRIE_STORE_REVCHAR() was creating SvPV()s with no trailing '\0'. This
78f1eb
doesn't really matter given the specialised use these are put to, but
78f1eb
it upset valgrind et al when perl was run with -Drv which printf("%s")'s
78f1eb
the contents of the string.
78f1eb
78f1eb
Signed-off-by: Petr Písař <ppisar@redhat.com>
78f1eb
---
78f1eb
 regcomp.c | 3 ++-
78f1eb
 1 file changed, 2 insertions(+), 1 deletion(-)
78f1eb
78f1eb
diff --git a/regcomp.c b/regcomp.c
78f1eb
index 370221f72e..1117998fc8 100644
78f1eb
--- a/regcomp.c
78f1eb
+++ b/regcomp.c
78f1eb
@@ -2526,7 +2526,8 @@ is the recommended Unicode-aware way of saying
78f1eb
 	if (UTF) {							   \
78f1eb
             SV *zlopp = newSV(UTF8_MAXBYTES);				   \
78f1eb
 	    unsigned char *flrbbbbb = (unsigned char *) SvPVX(zlopp);	   \
78f1eb
-            unsigned const char *const kapow = uvchr_to_utf8(flrbbbbb, val); \
78f1eb
+            unsigned char *const kapow = uvchr_to_utf8(flrbbbbb, val);     \
78f1eb
+            *kapow = '\0';                                                 \
78f1eb
 	    SvCUR_set(zlopp, kapow - flrbbbbb);				   \
78f1eb
 	    SvPOK_on(zlopp);						   \
78f1eb
 	    SvUTF8_on(zlopp);						   \
78f1eb
-- 
78f1eb
2.20.1
78f1eb