diff options
author | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2022-07-26 23:03:18 +0100 |
---|---|---|
committer | Paul Evans <leonerd@leonerd.org.uk> | 2022-08-03 09:52:06 +0100 |
commit | 4dd48237e57323de056710e155ba3be1fd67c65f (patch) | |
tree | 86496988954f700961fbf23d88a98a2b2527ce28 /op.c | |
parent | 4b0ceb86a69dee7c4031370d54c78b64f3c3ee06 (diff) | |
download | perl-4dd48237e57323de056710e155ba3be1fd67c65f.tar.gz |
OP_RUNCV should be created by newSVOP()
This is in case rpeep converts it into an OP_CONST; it will need the
space big enough to be a full SVOP.
Before this commit it called `newPVOP()` which wasn't technically
correct, but since sizeof(PVOP) == sizeof(SVOP) nothing actually broke
when the memory slab was reused. However if the definition of either op
type is changed so this is no longer the case, it may cause otherwise
hard-to-debug memory corruption.
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -7335,9 +7335,12 @@ Perl_newSVOP(pTHX_ I32 type, I32 flags, SV *sv) PERL_ARGS_ASSERT_NEWSVOP; + /* OP_RUNCV is allowed specially so rpeep has room to convert it into an + * OP_CONST */ assert((PL_opargs[type] & OA_CLASS_MASK) == OA_SVOP || (PL_opargs[type] & OA_CLASS_MASK) == OA_PVOP_OR_SVOP || (PL_opargs[type] & OA_CLASS_MASK) == OA_FILESTATOP + || type == OP_RUNCV || type == OP_CUSTOM); NewOp(1101, svop, 1, SVOP); @@ -7459,7 +7462,7 @@ Perl_newPVOP(pTHX_ I32 type, I32 flags, char *pv) flags &= ~SVf_UTF8; assert((PL_opargs[type] & OA_CLASS_MASK) == OA_PVOP_OR_SVOP - || type == OP_RUNCV || type == OP_CUSTOM + || type == OP_CUSTOM || (PL_opargs[type] & OA_CLASS_MASK) == OA_LOOPEXOP); NewOp(1101, pvop, 1, PVOP); @@ -13926,7 +13929,7 @@ Perl_ck_entersub_args_core(pTHX_ OP *entersubop, GV *namegv, SV *protosv) } return opnum == OP_RUNCV - ? newPVOP(OP_RUNCV,0,NULL) + ? newSVOP(OP_RUNCV, 0, &PL_sv_undef) : newOP(opnum,0); default: return op_convert_list(opnum,0,aop); |