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