Avoid stomping off the beginning of an array in tr///.
Jarkko Hietaniemi [Thu, 15 Mar 2001 01:05:01 +0000 (01:05 +0000)]
p4raw-id: //depot/perl@9164

op.c

diff --git a/op.c b/op.c
index 421dc9e..64914ea 100644 (file)
--- a/op.c
+++ b/op.c
@@ -2872,11 +2872,8 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
                }
            }
        }
-       if (!del) {
-           if (j >= rlen)
-               j = rlen - 1;
-           else
-               cPVOPo->op_pv = (char*)Renew(tbl, 0x101+rlen-j, short);
+       if (!del && rlen >= j) {
+           cPVOPo->op_pv = (char*)Renew(tbl, 0x101+rlen-j, short);
            tbl[0x100] = rlen - j;
            for (i=0; i < rlen - j; i++)
                tbl[0x101+i] = r[j+i];