arybase.xs: Check that $[ is in the main stash
authorFather Chrysostomos <sprout@cpan.org>
Thu, 17 Nov 2011 17:35:53 +0000 (09:35 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 17 Nov 2011 18:22:24 +0000 (10:22 -0800)
Check that $[ is in the main stash before doing anything magical with
$[=1.  This can only be in another stash if some other XS module has
overridden the check functions to change $[ to $foo::[.  But robust-
ness is good, right?

ext/arybase/arybase.xs

index 5c653e3..7cee0dc 100644 (file)
@@ -137,6 +137,7 @@ STATIC bool ab_op_is_dollar_bracket(pTHX_ OP *o) {
  return o->op_type == OP_RV2SV && (o->op_flags & OPf_KIDS)
   && (c = cUNOPx(o)->op_first)
   && c->op_type == OP_GV
+  && GvSTASH(cGVOPx_gv(c)) == PL_defstash
   && strEQ(GvNAME(cGVOPx_gv(c)), "[");
 }