This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
For consistency sv_2cv should not leave the stash pointer uninitialised
authorNicholas Clark <nick@ccl4.org>
Wed, 21 Dec 2005 21:20:23 +0000 (21:20 +0000)
committerNicholas Clark <nick@ccl4.org>
Wed, 21 Dec 2005 21:20:23 +0000 (21:20 +0000)
for some cases. Although it seems that only pp_sort pays any attention
to it, of all the code on CPAN.

p4raw-id: //depot/perl@26438

sv.c

diff --git a/sv.c b/sv.c
index a6f0866..38dfb6f 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -6734,7 +6734,7 @@ Perl_sv_2cv(pTHX_ SV *sv, HV **st, GV **gvp, I32 lref)
     CV *cv = Nullcv;
 
     if (!sv)
-       return *gvp = Nullgv, Nullcv;
+       return *st = NULL, *gvp = Nullgv, Nullcv;
     switch (SvTYPE(sv)) {
     case SVt_PVCV:
        *st = CvSTASH(sv);
@@ -6742,6 +6742,7 @@ Perl_sv_2cv(pTHX_ SV *sv, HV **st, GV **gvp, I32 lref)
        return (CV*)sv;
     case SVt_PVHV:
     case SVt_PVAV:
+       *st = NULL;
        *gvp = Nullgv;
        return Nullcv;
     case SVt_PVGV:
@@ -6773,8 +6774,10 @@ Perl_sv_2cv(pTHX_ SV *sv, HV **st, GV **gvp, I32 lref)
        else
            gv = gv_fetchsv(sv, lref, SVt_PVCV);
        *gvp = gv;
-       if (!gv)
+       if (!gv) {
+           *st = NULL;
            return Nullcv;
+       }
        *st = GvESTASH(gv);
     fix_gv:
        if (lref && !GvCVu(gv)) {