Change 30267 by [EMAIL PROTECTED] on 2007/02/13 20:11:08
Subject: Re: Segmentation fault at undeclared for loop variable
From: Robin Houston <[EMAIL PROTECTED]>
Date: Tue, 13 Feb 2007 16:50:08 +0000
Message-Id: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/op.c#893 edit
Differences ...
==== //depot/perl/op.c#893 (text) ====
Index: perl/op.c
--- perl/op.c#892~30105~ 2007-02-03 07:23:52.000000000 -0800
+++ perl/op.c 2007-02-13 12:11:08.000000000 -0800
@@ -4521,7 +4521,15 @@
iterpflags = sv->op_private & OPpOUR_INTRO; /* for our $x () */
sv->op_type = OP_RV2GV;
sv->op_ppaddr = PL_ppaddr[OP_RV2GV];
- if (cGVOPx_gv(cUNOPx(sv)->op_first) == PL_defgv)
+
+ /* The op_type check is needed to prevent a possible segfault
+ * if the loop variable is undeclared and 'strict vars' is in
+ * effect. This is illegal but is nonetheless parsed, so we
+ * may reach this point with an OP_CONST where we're expecting
+ * an OP_GV.
+ */
+ if (cUNOPx(sv)->op_first->op_type == OP_GV
+ && cGVOPx_gv(cUNOPx(sv)->op_first) == PL_defgv)
iterpflags |= OPpITER_DEF;
}
else if (sv->op_type == OP_PADSV) { /* private variable */
End of Patch.