This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid a segfault when untying an object
authorNicolas R <atoomic@cpan.org>
Mon, 31 Oct 2016 17:53:17 +0000 (11:53 -0600)
committerNicolas R <atoomic@cpan.org>
Thu, 2 Nov 2017 22:32:40 +0000 (17:32 -0500)
Check if the tied object has a stash set
before calling UNTIE method.

pp_sys.c

index 672e7de..6d4dd86 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1017,7 +1017,7 @@ PP(pp_untie)
 
     if ((mg = SvTIED_mg(sv, how))) {
        SV * const obj = SvRV(SvTIED_obj(sv, mg));
-        if (obj) {
+        if (obj && SvSTASH(obj)) {
            GV * const gv = gv_fetchmethod_autoload(SvSTASH(obj), "UNTIE", FALSE);
            CV *cv;
            if (gv && isGV(gv) && (cv = GvCV(gv))) {