Possible future bugs found by the creation of newSVpvn_flags().
Nicholas Clark [Thu, 3 Jan 2008 14:24:29 +0000 (14:24 +0000)]
But use newSVhek() in preference when possible.

p4raw-id: //depot/perl@32813

perl.c
pp.c
regcomp.c
sv.c

diff --git a/perl.c b/perl.c
index 82412d2..6095df7 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -4952,7 +4952,8 @@ S_incpush(pTHX_ const char *dir, bool addsubdirs, bool addoldvers, bool usesep,
                   SvPOK() won't be true.  */
                assert(caret_X);
                assert(SvPOKp(caret_X));
-               prefix_sv = newSVpvn(SvPVX(caret_X), SvCUR(caret_X));
+               prefix_sv = newSVpvn_flags(SvPVX(caret_X), SvCUR(caret_X),
+                                          SvUTF8(caret_X));
                /* Firstly take off the leading .../
                   If all else fail we'll do the paths relative to the current
                   directory.  */
diff --git a/pp.c b/pp.c
index 3ac702d..1202fb1 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -624,7 +624,7 @@ PP(pp_gelem)
            break;
        case 'N':
            if (strEQ(second_letter, "AME"))
-               sv = newSVpvn(GvNAME(gv), GvNAMELEN(gv));
+               sv = newSVhek(GvNAME_HEK(gv));
            break;
        case 'P':
            if (strEQ(second_letter, "ACKAGE")) {
index e384ff5..6d75613 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -5001,9 +5001,7 @@ Perl_reg_named_buff_nextkey(pTHX_ REGEXP * const r, const U32 flags)
                 }
             }
             if (parno || flags & RXapif_ALL) {
-                STRLEN len;
-                char *pv = HePV(temphe, len);
-                return newSVpvn(pv,len);
+               return newSVhek(HeKEY_hek(temphe));
             }
         }
     }
@@ -5059,9 +5057,7 @@ Perl_reg_named_buff_all(pTHX_ REGEXP * const r, const U32 flags)
                 }
             }
             if (parno || flags & RXapif_ALL) {
-                STRLEN len;
-                char *pv = HePV(temphe, len);
-                av_push(av, newSVpvn(pv,len));
+                av_push(av, newSVhek(HeKEY_hek(temphe)));
             }
         }
     }
diff --git a/sv.c b/sv.c
index f8d3924..6010e4f 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -11836,7 +11836,7 @@ S_find_hash_subscript(pTHX_ HV *hv, SV* val)
                return NULL;
            if (HeKLEN(entry) == HEf_SVKEY)
                return sv_mortalcopy(HeKEY_sv(entry));
-           return sv_2mortal(newSVpvn(HeKEY(entry), HeKLEN(entry)));
+           return sv_2mortal(newSVhek(HeKEY_hek(entry)));
        }
     }
     return NULL;