summaryrefslogtreecommitdiff
path: root/cop.h
diff options
context:
space:
mode:
Diffstat (limited to 'cop.h')
-rw-r--r--cop.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/cop.h b/cop.h
index 6ea045a4a4..e8221b610c 100644
--- a/cop.h
+++ b/cop.h
@@ -66,17 +66,22 @@ struct block_sub {
#define POPSAVEARRAY() \
STMT_START { \
SvREFCNT_dec(GvAV(PL_defgv)); \
- GvAV(PL_defgv) = cxsub.savearray; \
+ GvAV(PL_defgv) = cxsub.savearray; \
} STMT_END
#endif /* USE_THREADS */
#define POPSUB2() \
if (cxsub.hasargs) { \
POPSAVEARRAY(); \
- /* destroy arg array */ \
- av_clear(cxsub.argarray); \
- AvREAL_off(cxsub.argarray); \
- AvREIFY_on(cxsub.argarray); \
+ /* abandon @_ if it got reified */ \
+ if (AvREAL(cxsub.argarray)) { \
+ SSize_t fill = AvFILLp(cxsub.argarray); \
+ SvREFCNT_dec(cxsub.argarray); \
+ cxsub.argarray = newAV(); \
+ av_extend(cxsub.argarray, fill); \
+ AvFLAGS(cxsub.argarray) = AVf_REIFY; \
+ PL_curpad[0] = (SV*)cxsub.argarray; \
+ } \
} \
if (cxsub.cv) { \
if (!(CvDEPTH(cxsub.cv) = cxsub.olddepth)) \