Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 3ef3aad

Browse files
author
Reini Urban
committed
mderef_u: AvSHAPED cannot have magic
so use AvFILLp instead.
1 parent f458a32 commit 3ef3aad

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

op.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13293,7 +13293,7 @@ Perl_ck_aelem(pTHX_ OP *o)
1329313293
AV* av = MUTABLE_AV(PAD_SV(avop->op_targ));
1329413294
if (idx && SvIOK(idx) && AvSHAPED(av)) {
1329513295
IV ix = SvIVX(idx);
13296-
if (PERL_IABS(ix) > AvFILL(av))
13296+
if (PERL_IABS(ix) > AvFILLp(av))
1329713297
Perl_die(aTHX_ "Array index out of bounds %s[%"IVdf"]",
1329813298
PAD_COMPNAME_PV(avop->op_targ), ix);
1329913299
else {
@@ -14320,15 +14320,15 @@ S_maybe_multideref(pTHX_ OP *start, OP *orig_o, UV orig_action, U8 hints)
1432014320
PADOFFSET targ = (((BINOP*)aelem_op)->op_first)->op_targ;
1432114321
SV* av; /* targ may still be empty here */
1432214322
if (targ && (av = PAD_SV(targ)) && AvSHAPED(av)) {
14323-
if (PERL_IABS(arg->iv) > AvFILL(av))
14323+
if (PERL_IABS(arg->iv) > AvFILLp(av))
1432414324
Perl_die(aTHX_ "Array index out of bounds %s[%"IVdf"]",
1432514325
PAD_COMPNAME_PV(targ), arg->iv);
1432614326
else {
1432714327
DEBUG_kv(Perl_deb(aTHX_
1432814328
"mderef %s[%"IVdf"] shape ok -> uoob\n",
1432914329
PAD_COMPNAME_PV(targ), arg->iv));
1433014330
if (arg->iv < 0) {
14331-
arg->iv = AvFILL(av)+1+arg->iv;
14331+
arg->iv = AvFILLp(av)+1+arg->iv;
1433214332
DEBUG_kv(Perl_deb(aTHX_
1433314333
"mderef %s[->%"IVdf"]\n",
1433414334
PAD_COMPNAME_PV(targ), arg->iv));
@@ -15232,7 +15232,7 @@ Perl_rpeep(pTHX_ OP *o)
1523215232
&& strEQ(aname, SvPVX(kSVOP_sv))) {
1523315233
/* TODO no magic in array allowed, array must be typed */
1523415234
if (o2->op_targ && o2->op_targ == loop->op_targ) {
15235-
DEBUG_k(Perl_deb(aTHX_ "loop oob: aelemfast %s[my %s] => aelemfast_u\n",
15235+
DEBUG_k(Perl_deb(aTHX_ "loop oob: aelemfast %s[my %s] => aelemfast_lex_u\n",
1523615236
aname, iname));
1523715237
OpTYPE_set(o2, OP_AELEMFAST_LEX_U);
1523815238
}
@@ -15631,8 +15631,8 @@ Perl_rpeep(pTHX_ OP *o)
1563115631
/* FALLTHROUGH */
1563215632
case OP_GV:
1563315633
if (o->op_type == OP_PADAV || o->op_next->op_type == OP_RV2AV) {
15634-
OP* const pop = (o->op_type == OP_PADAV) ?
15635-
o->op_next : o->op_next->op_next;
15634+
OP* const pop = (o->op_type == OP_PADAV)
15635+
? o->op_next : o->op_next->op_next;
1563615636
IV i;
1563715637
if (pop && pop->op_type == OP_CONST &&
1563815638
((PL_op = pop->op_next)) &&
@@ -15662,17 +15662,24 @@ Perl_rpeep(pTHX_ OP *o)
1566215662
if (AvSHAPED(av)) {
1566315663
#ifndef AELEMSIZE_RT_NEGATIVE
1566415664
if (i < 0) {
15665-
IV ix = AvFILL(av)+1+i;
15666-
if (ix <= 255)
15665+
IV ix = AvFILLp(av)+1+i;
15666+
if (ix <= 255) {
1566715667
o->op_private = (U8)ix;
15668+
DEBUG_k(Perl_deb(aTHX_ "aelemfast_lex_u %s[->%"IVdf"]\n",
15669+
PAD_COMPNAME_PV(o->op_targ), ix));
15670+
}
1566815671
else
1566915672
goto lex;
1567015673
}
1567115674
#endif
1567215675
o->op_type = OP_AELEMFAST_LEX_U;
1567315676
o->op_ppaddr = PL_ppaddr[OP_AELEMFAST_LEX_U];
15677+
DEBUG_k(Perl_deb(aTHX_ "rpeep: aelemfast %s => aelemfast_lex_u\n",
15678+
PAD_COMPNAME_PV(o->op_targ)));
1567415679
} else {
1567515680
lex:
15681+
DEBUG_k(Perl_deb(aTHX_ "rpeep: aelemfast %s => aelemfast_lex\n",
15682+
PAD_COMPNAME_PV(o->op_targ)));
1567615683
o->op_type = OP_AELEMFAST_LEX;
1567715684
o->op_ppaddr = PL_ppaddr[OP_AELEMFAST];
1567815685
}

0 commit comments

Comments
 (0)