34484a
From 62e6b70574842d7f2c547d33c85c50228522f685 Mon Sep 17 00:00:00 2001
34484a
From: Marc-Philip <marc-philip.werner@sap.com>
34484a
Date: Sun, 8 Apr 2018 12:15:29 -0600
34484a
Subject: [PATCH] PATCH: [perl #133074] 5.26.1: some coverity fixes
34484a
MIME-Version: 1.0
34484a
Content-Type: text/plain; charset=UTF-8
34484a
Content-Transfer-Encoding: 8bit
34484a
34484a
we have some coverity code scans here. They have found this
34484a
uninilialized variable in pp.c and the integer overrun in toke.c.
34484a
Though it might be possible that these are false positives (no
34484a
reasonable control path gets there), it's good to mute the scan here to
34484a
see the real problems easier.
34484a
34484a
Signed-off-by: Petr Písař <ppisar@redhat.com>
34484a
---
34484a
 pp.c   | 1 +
34484a
 toke.c | 8 ++++----
34484a
 2 files changed, 5 insertions(+), 4 deletions(-)
34484a
34484a
diff --git a/pp.c b/pp.c
34484a
index 5524131658..d777ae4309 100644
34484a
--- a/pp.c
34484a
+++ b/pp.c
34484a
@@ -3727,6 +3727,7 @@ PP(pp_ucfirst)
34484a
     if (! slen) {   /* If empty */
34484a
 	need = 1; /* still need a trailing NUL */
34484a
 	ulen = 0;
34484a
+        *tmpbuf = '\0';
34484a
     }
34484a
     else if (DO_UTF8(source)) {	/* Is the source utf8? */
34484a
 	doing_utf8 = TRUE;
34484a
diff --git a/toke.c b/toke.c
34484a
index 3405dc6c89..fc87252bb1 100644
34484a
--- a/toke.c
34484a
+++ b/toke.c
34484a
@@ -9052,7 +9052,7 @@ S_pending_ident(pTHX)
34484a
 		HEK * const stashname = HvNAME_HEK(stash);
34484a
 		SV *  const sym = newSVhek(stashname);
34484a
                 sv_catpvs(sym, "::");
34484a
-                sv_catpvn_flags(sym, PL_tokenbuf+1, tokenbuf_len - 1, (UTF ? SV_CATUTF8 : SV_CATBYTES ));
34484a
+                sv_catpvn_flags(sym, PL_tokenbuf+1, tokenbuf_len > 0 ? tokenbuf_len - 1 : 0, (UTF ? SV_CATUTF8 : SV_CATBYTES ));
34484a
                 pl_yylval.opval = newSVOP(OP_CONST, 0, sym);
34484a
                 pl_yylval.opval->op_private = OPpCONST_ENTERED;
34484a
                 if (pit != '&')
34484a
@@ -9080,7 +9080,7 @@ S_pending_ident(pTHX)
34484a
         && PL_lex_state != LEX_NORMAL
34484a
         && !PL_lex_brackets)
34484a
     {
34484a
-        GV *const gv = gv_fetchpvn_flags(PL_tokenbuf + 1, tokenbuf_len - 1,
34484a
+        GV *const gv = gv_fetchpvn_flags(PL_tokenbuf + 1, tokenbuf_len > 0 ? tokenbuf_len - 1 : 0,
34484a
                                          ( UTF ? SVf_UTF8 : 0 ) | GV_ADDMG,
34484a
                                          SVt_PVAV);
34484a
         if ((!gv || ((PL_tokenbuf[0] == '@') ? !GvAV(gv) : !GvHV(gv)))
34484a
@@ -9097,11 +9097,11 @@ S_pending_ident(pTHX)
34484a
     /* build ops for a bareword */
34484a
     pl_yylval.opval = newSVOP(OP_CONST, 0,
34484a
 				   newSVpvn_flags(PL_tokenbuf + 1,
34484a
-						      tokenbuf_len - 1,
34484a
+                                                      tokenbuf_len > 0 ? tokenbuf_len - 1 : 0,
34484a
                                                       UTF ? SVf_UTF8 : 0 ));
34484a
     pl_yylval.opval->op_private = OPpCONST_ENTERED;
34484a
     if (pit != '&')
34484a
-	gv_fetchpvn_flags(PL_tokenbuf+1, tokenbuf_len - 1,
34484a
+        gv_fetchpvn_flags(PL_tokenbuf+1, tokenbuf_len > 0 ? tokenbuf_len - 1 : 0,
34484a
 		     (PL_in_eval ? GV_ADDMULTI : GV_ADD)
34484a
                      | ( UTF ? SVf_UTF8 : 0 ),
34484a
 		     ((PL_tokenbuf[0] == '$') ? SVt_PV
34484a
-- 
34484a
2.14.3
34484a