summaryrefslogtreecommitdiff
path: root/pad.c
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2012-02-25 15:41:17 +0000
committerZefram <zefram@fysh.org>2012-02-25 15:49:01 +0000
commit9100eeb186d403d6c6c6ef15844209cad5a9b9f0 (patch)
tree711e77c82c5995fd558d5b175490419a80ab43f3 /pad.c
parent236cbe8d7a6747fb6144c93dd767895f8acffd00 (diff)
downloadperl-9100eeb186d403d6c6c6ef15844209cad5a9b9f0.tar.gz
delay allocating trans table until needed
Previously, a table was being allocated for OP_TRANS(|R), in a PVOP arrangement, as soon as the op was built. However, it wasn't used immediately, and for UTF8-flagged ops it would be thrown away, replaced by an SV-based translation table in a SVOP or PADOP arrangement. This mutation of the op structure occurred in pmtrans(), some time after original op building. If an error occurred before pmtrans(), requiring the op to be freed, op_clear() would be misled by the UTF8 flags into treating the PV as an SV or pad index, causing crashes in the latter case [perl #102858]. op_clear() was implicitly assuming that pmtrans() had been performed, due to lacking any explicit indication of the op's state of construction. Now, the PV table is allocated by pmtrans(), when it's actually going to populate it. The PV doesn't get allocated at all for UTF8-flagged ops. Prior to pmtrans(), the op_pv/op_sv/op_padix field is all bits zero, so there's no problem with freeing the op.
Diffstat (limited to 'pad.c')
-rw-r--r--pad.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/pad.c b/pad.c
index 779e6d6708..c4362af0d4 100644
--- a/pad.c
+++ b/pad.c
@@ -1516,8 +1516,9 @@ Perl_pad_swipe(pTHX_ PADOFFSET po, bool refadjust)
if (AvARRAY(PL_comppad) != PL_curpad)
Perl_croak(aTHX_ "panic: pad_swipe curpad, %p!=%p",
AvARRAY(PL_comppad), PL_curpad);
- if (!po)
- Perl_croak(aTHX_ "panic: pad_swipe po");
+ if (!po || ((SSize_t)po) > AvFILLp(PL_comppad))
+ Perl_croak(aTHX_ "panic: pad_swipe po=%ld, fill=%ld",
+ (long)po, (long)AvFILLp(PL_comppad));
DEBUG_X(PerlIO_printf(Perl_debug_log,
"Pad 0x%"UVxf"[0x%"UVxf"] swipe: %ld\n",