aboutsummaryrefslogtreecommitdiff
path: root/lang/perl5.16/files/patch-bug71952
blob: c36c7d721edb58186dc841bff076f97483a6c147 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# http://rt.perl.org/rt3/Public/Bug/Display.html?id=71952
# http://perl5.git.perl.org/perl.git/commitdiff_plain/1f15e670edb515b744e9021b4a42a7955da83093?hp=1f730e6c11736bad913e605b064200a67117e898
diff --git a/sv.c b/sv.c
index 4e80e18..a3eb187 100644
--- sv.c
+++ sv.c
@@ -5664,7 +5664,8 @@ Perl_sv_clear(pTHX_ register SV *const sv)
 			&& !CvCONST(destructor)
 			/* Don't bother calling an empty destructor */
 			&& (CvISXSUB(destructor)
-			|| CvSTART(destructor)->op_next->op_type != OP_LEAVESUB))
+			|| (CvSTART(destructor)
+			    && (CvSTART(destructor)->op_next->op_type != OP_LEAVESUB))))
 		{
 		    SV* const tmpref = newRV(sv);
 	            SvREADONLY_on(tmpref);   /* DESTROY() could be naughty */
diff --git a/t/op/method.t b/t/op/method.t
index afa8cfb..b602ca2 100644
--- t/op/method.t
+++ t/op/method.t
@@ -10,7 +10,7 @@ BEGIN {
     require "test.pl";
 }
 
-print "1..78\n";
+print "1..79\n";
 
 @A::ISA = 'B';
 @B::ISA = 'C';
@@ -292,3 +292,16 @@ EOT
 	"check if UNIVERSAL::AUTOLOAD works",
     );
 }
+
+# Test for #71952: crash when looking for a nonexistent destructor
+# Regression introduced by fbb3ee5af3d4
+{
+    fresh_perl_is(<<'EOT',
+sub M::DESTROY; bless {}, "M" ; print "survived\n";
+EOT
+    "survived",
+    {},
+	"no crash with a declared but missing DESTROY method"
+    );
+}
+