summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2017-07-04 09:45:29 +0100
committerDavid Mitchell <davem@iabyn.com>2017-07-27 11:30:21 +0100
commit725c44f93c35f696d7175c36a6d2ec5987b5a4d1 (patch)
tree721f07a19addb4cffc53b5d7736dae71f68c01fb /pp_sys.c
parentb043c4bf3fff5c679dad74f1a0c13ac539a97815 (diff)
downloadperl-725c44f93c35f696d7175c36a6d2ec5987b5a4d1.tar.gz
use the new PL_sv_zero in obvious places
In places that do things like mPUSHi(0) or newSViv(0), replace them with PUSHs(&PL_sv_zero) and &PL_sv_zero, etc. This avoids the cost of creating and/or mortalising an SV, and/or setting its value to 0. This commit causes a subtle change to tainting in various places as a side-effect. For example, grep in scalar context retunrs 0 if it has no args. Formerly the zero value could in theory get tainted: @a = (); $x = ( ($^X . ""), grep { 1 } @a); It used to be the case that $x would be tainted; now its not. In practice this doesn't matter - the zero value was only getting tainted as a side-effect of tainting's "if anything in the statement uses a tainted value, taint everything" mechanism, which gives (documented) false positives. This commit merely removes some such false positives, and makes the behaviour similar to functions which return &PL_sv_undef/no/yes, which are also immune to side-effect tainting.
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 100762c1b7..e6ed385d65 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -655,7 +655,7 @@ PP(pp_open)
if (ok)
PUSHi( (I32)PL_forkprocess );
else if (PL_forkprocess == 0) /* we are a new child */
- PUSHi(0);
+ PUSHs(&PL_sv_zero);
else
RETPUSHUNDEF;
RETURN;
@@ -3660,7 +3660,7 @@ PP(pp_chdir)
"chdir() on unopened filehandle %" SVf, sv);
}
SETERRNO(EBADF,RMS_IFI);
- PUSHi(0);
+ PUSHs(&PL_sv_zero);
TAINT_PROPER("chdir");
RETURN;
}
@@ -3683,7 +3683,7 @@ PP(pp_chdir)
tmps = SvPV_nolen_const(*svp);
}
else {
- PUSHi(0);
+ PUSHs(&PL_sv_zero);
SETERRNO(EINVAL, LIB_INVARG);
TAINT_PROPER("chdir");
RETURN;
@@ -3728,7 +3728,7 @@ PP(pp_chdir)
nuts:
report_evil_fh(gv);
SETERRNO(EBADF,RMS_IFI);
- PUSHi(0);
+ PUSHs(&PL_sv_zero);
RETURN;
#endif
}
@@ -4871,7 +4871,7 @@ PP(pp_sleep)
Perl_ck_warner_d(aTHX_ packWARN(WARN_MISC),
"sleep() with negative argument");
SETERRNO(EINVAL, LIB_INVARG);
- XPUSHi(0);
+ XPUSHs(&PL_sv_zero);
RETURN;
} else {
PerlProc_sleep((unsigned int)duration);