summaryrefslogtreecommitdiff
path: root/mathoms.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-10-25 13:00:55 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-10-25 20:02:55 -0700
commit3ed356df9354193bbcc5202f066f3c07ae84b443 (patch)
tree6a9fd54462d581f52672a517b461498fb798166e /mathoms.c
parent33b889b0162a4f12e7c2a8d184afb63213130f07 (diff)
downloadperl-3ed356df9354193bbcc5202f066f3c07ae84b443.tar.gz
[perl #115440] Fix various leaks with fatal FETCH
Various pieces of code were creating an SV and then assigning to it from a value that might be magical. If the source scalar is magical, it could die when magic is called, leaking the scalar that would have been assigned to. So we call get-magic before creating the new scalar, and then use a non-magical assignment. Also, anonhash and anonlist were doing nothing to protect the aggre- gate if an argument should die on FETCH, resulting in a leak.
Diffstat (limited to 'mathoms.c')
-rw-r--r--mathoms.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/mathoms.c b/mathoms.c
index e8d81054a0..e19b24c638 100644
--- a/mathoms.c
+++ b/mathoms.c
@@ -804,8 +804,10 @@ Perl_save_list(pTHX_ register SV **sarg, I32 maxsarg)
PERL_ARGS_ASSERT_SAVE_LIST;
for (i = 1; i <= maxsarg; i++) {
- SV * const sv = newSV(0);
- sv_setsv(sv,sarg[i]);
+ SV *sv;
+ SvGETMAGIC(sarg[i]);
+ sv = newSV(0);
+ sv_setsv_nomg(sv,sarg[i]);
SSCHECK(3);
SSPUSHPTR(sarg[i]); /* remember the pointer */
SSPUSHPTR(sv); /* remember the value */