summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2011-12-13 22:10:53 -0700
committerKarl Williamson <public@khwilliamson.com>2011-12-15 16:26:01 -0700
commitb6f93e7a99237718d236ae85a09f11426741878a (patch)
tree6a113f2db9b6cb3f85c99d4289167689138cd561 /scope.c
parent094a2f8c3da82fac9e0698c2daeb7e94d0ae765a (diff)
downloadperl-b6f93e7a99237718d236ae85a09f11426741878a.tar.gz
scope.c: Allow successful saving of PL_tainted
leave_scope() saves and restores PL_tainted upon entry and exit. This means that any attempt to save this variable on the stack will fail, as its unstacked value will overwrite the popped one. To counteract this, we update our saved version with the popped value.
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/scope.c b/scope.c
index cb0e8c5b35..53bc9dfaf1 100644
--- a/scope.c
+++ b/scope.c
@@ -709,7 +709,7 @@ Perl_leave_scope(pTHX_ I32 base)
register char* str;
I32 i;
/* Localise the effects of the TAINT_NOT inside the loop. */
- const bool was = PL_tainted;
+ bool was = PL_tainted;
if (base < -1)
Perl_croak(aTHX_ "panic: corrupt saved stack index");
@@ -813,6 +813,15 @@ Perl_leave_scope(pTHX_ I32 base)
case SAVEt_BOOL: /* bool reference */
ptr = SSPOPPTR;
*(bool*)ptr = cBOOL(uv >> 8);
+
+ if (ptr == &PL_tainted) {
+ /* If we don't update <was>, to reflect what was saved on the
+ * stack for PL_tainted, then we will overwrite this attempt to
+ * restore it when we exit this routine. Note that this won't
+ * work if this value was saved in a wider-than necessary type,
+ * such as I32 */
+ was = *(bool*)ptr;
+ }
break;
case SAVEt_I32_SMALL:
ptr = SSPOPPTR;