From: Jarkko Hietaniemi Date: Tue, 12 Aug 2003 07:59:22 +0000 (+0000) Subject: Fix for [perl #23287] segfault in untie. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b7056d9c698177a62c525b2c6e1f5368fe56e6c5;p=p5sagit%2Fp5-mst-13.2.git Fix for [perl #23287] segfault in untie. (Well, at least no more coredump.) p4raw-id: //depot/perl@20630 --- diff --git a/pp_sys.c b/pp_sys.c index b240b62..910fb14 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -860,7 +860,7 @@ PP(pp_untie) if (SvTYPE(sv) == SVt_PVGV && !(sv = (SV *)GvIOp(sv))) RETPUSHYES; - if ((mg = SvTIED_mg(sv, how))) { + if ((mg = SvTIED_mg(sv, how)) && mg->mg_obj) { SV *obj = SvRV(mg->mg_obj); GV *gv; CV *cv = NULL; diff --git a/t/op/tie.t b/t/op/tie.t index a3b4be2..d73cce1 100755 --- a/t/op/tie.t +++ b/t/op/tie.t @@ -360,3 +360,10 @@ $s=~ s/\(0x\w+\)//g; print $s, "\n"; EXPECT SCALAR SCALAR SCALAR SCALAR +######## +# [perl #23287] segfault in untie +sub TIESCALAR { bless $_[1], $_[0] } +my $var; +tie $var, 'main', \$var; +untie $var; +EXPECT