summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-07-26 01:26:54 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-08-25 12:25:23 -0700
commit35995e5cabcbf47f272bbb0fb290908515c1d776 (patch)
tree4ac6fe162e158e5b465168b2e628ab2d5cdefd29 /mg.c
parent232af1f839acc29d9ac336d13ff67802d236c38b (diff)
downloadperl-35995e5cabcbf47f272bbb0fb290908515c1d776.tar.gz
Fix assert fail when fetching pos clobbers ref with undef
pos($x) returns a special magical scalar that sets the match position on $x. Calling pos($x) twice will provide two such scalars. If we set one of them to a reference, set the other to undef, and then read the first, all hail breaks loose, because of the use of SvOK_off. SvOK_off is not sufficient if arbitrary values can be assigned by Perl code. Globs, refs and regexps (among others) need special handling, which sv_setsv knows how to do.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mg.c b/mg.c
index ea912b3412..604fe6bb05 100644
--- a/mg.c
+++ b/mg.c
@@ -2105,7 +2105,7 @@ Perl_magic_getpos(pTHX_ SV *sv, MAGIC *mg)
sv_setuv(sv, i);
return 0;
}
- SvOK_off(sv);
+ sv_setsv(sv,NULL);
return 0;
}