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