]> git.vpit.fr Git - perl/modules/indirect.git/blobdiff - indirect.xs
Better logic for finding oo and om in ck_entersub
[perl/modules/indirect.git] / indirect.xs
index 6909bf44a1055576a801bb577befa800afed28a8..aa2e69198efcc9caf25dabb40ad9f88ef969a3d2 100644 (file)
 
 STATIC U32 indirect_hash = 0;
 
-STATIC UV indirect_hint(pTHX) {
+STATIC IV indirect_hint(pTHX) {
 #define indirect_hint() indirect_hint(aTHX)
  SV *id = Perl_refcounted_he_fetch(aTHX_ PL_curcop->cop_hints_hash,
                                          NULL,
                                          "indirect", 8,
                                          0,
                                          indirect_hash);
- return SvOK(id) ? SvUV(id) : 0;
+ return (id && SvOK(id) && SvIOK(id)) ? SvIV(id) : 0;
 }
 
 /* ... op -> source position ............................................... */
@@ -58,6 +58,8 @@ STATIC void indirect_map_store(pTHX_ const OP *o, const char *src, SV *sv) {
  val = newSVsv(sv);
  SvUPGRADE(val, SVt_PVIV);
  SvUVX(val) = PTR2UV(src);
+ SvIOK_on(val);
+ SvIsUV_on(val);
  if (!hv_store(indirect_map, buf, sprintf(buf, "%u", PTR2UV(o)), val, 0))
   SvREFCNT_dec(val);
 }
@@ -185,18 +187,20 @@ STATIC OP *(*indirect_old_ck_entersub)(pTHX_ OP *) = 0;
 STATIC OP *indirect_ck_entersub(pTHX_ OP *o) {
  LISTOP *op;
  OP *om, *oo;
UV hint = indirect_hint();
IV hint = indirect_hint();
 
  if (hint) {
   const char *pm, *po;
   SV *svm, *svo;
-  op = (LISTOP *) o;
-  while (op->op_type != OP_PUSHMARK)
-   op = (LISTOP *) op->op_first;
-  oo = op->op_sibling;
-  om = oo;
-  while (om->op_sibling)
-   om = om->op_sibling;
+  oo = o;
+  do {
+   op = (LISTOP *) oo;
+   if (!op->op_flags & OPf_KIDS)
+    goto done;
+   oo = op->op_first;
+  } while (oo->op_type != OP_PUSHMARK);
+  oo = oo->op_sibling;
+  om = op->op_last;
   if (om->op_type == OP_METHOD)
    om = cUNOPx(om)->op_first;
   else if (om->op_type != OP_METHOD_NAMED)