Skip to content

Commit

Permalink
[perl #78194] Make x copy PADTMPs in lv cx
Browse files Browse the repository at this point in the history
So that \(("$a")x2) will give two references to the same scalar, the
way that \(($a)x2) does.
  • Loading branch information
Father Chrysostomos committed Jul 26, 2013
1 parent 706a6eb commit da9e430
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pp.c
Expand Up @@ -1657,6 +1657,7 @@ PP(pp_repeat)
static const char* const oom_list_extend = "Out of memory during list extend";
const I32 items = SP - MARK;
const I32 max = items * count;
const U8 mod = PL_op->op_flags & OPf_MOD;

MEM_WRAP_CHECK_1(max, SV*, oom_list_extend);
/* Did the max computation overflow? */
Expand Down Expand Up @@ -1690,7 +1691,11 @@ PP(pp_repeat)
}
#else
if (*SP)
{
if (mod && SvPADTMP(*SP) && !IS_PADGV(*SP))
*SP = sv_mortalcopy(*SP);
SvTEMP_off((*SP));
}
#endif
SP--;
}
Expand Down
1 change: 0 additions & 1 deletion t/op/repeat.t
Expand Up @@ -156,7 +156,6 @@ is(77, scalar ((1,7)x2), 'stack truncation');
is( (join ',', (qw(a b c) x 3)), 'a,b,c,a,b,c,a,b,c', 'x on qw produces list' );

# [perl #78194] x aliasing op return values
$::TODO = 'not fixed yet';
sub {
is(\$_[0], \$_[1],
'[perl #78194] \$_[0] == \$_[1] when @_ aliases elems repeated by x')
Expand Down

0 comments on commit da9e430

Please sign in to comment.