index() applied BM optimization to wrong argument
authorLarry Wall <larry@wall.org>
Sat, 5 Sep 1998 23:41:42 +0000 (23:41 +0000)
committerLarry Wall <larry@wall.org>
Sat, 5 Sep 1998 23:41:42 +0000 (23:41 +0000)
p4raw-id: //depot/perl@1779

op.c
util.c

diff --git a/op.c b/op.c
index 33a9efd..53fb8c1 100644 (file)
--- a/op.c
+++ b/op.c
@@ -4686,6 +4686,8 @@ ck_index(OP *o)
 {
     if (o->op_flags & OPf_KIDS) {
        OP *kid = cLISTOPo->op_first->op_sibling;       /* get past pushmark */
+       if (kid)
+           kid = kid->op_sibling;                      /* get past "big" */
        if (kid && kid->op_type == OP_CONST)
            fbm_compile(((SVOP*)kid)->op_sv, 0);
     }
diff --git a/util.c b/util.c
index e079d42..5be4969 100644 (file)
--- a/util.c
+++ b/util.c
@@ -900,10 +900,11 @@ fbm_compile(SV *sv, U32 flags /* not used yet */)
     register unsigned char *s;
     register unsigned char *table;
     register U32 i;
-    register U32 len = SvCUR(sv);
+    STRLEN len;
     I32 rarest = 0;
     U32 frequency = 256;
 
+    s = SvPV_force(sv, len);
     sv_upgrade(sv, SVt_PVBM);
     if (len > 255 || len == 0) /* TAIL might be on on a zero-length string. */
        return;                 /* can't have offsets that big */