summaryrefslogtreecommitdiff
path: root/av.c
diff options
context:
space:
mode:
Diffstat (limited to 'av.c')
-rw-r--r--av.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/av.c b/av.c
index 4718af28c8..a4d6ea2d06 100644
--- a/av.c
+++ b/av.c
@@ -404,8 +404,14 @@ Perl_av_make(pTHX_ register I32 size, register SV **strp)
AvFILLp(av) = AvMAX(av) = size - 1;
for (i = 0; i < size; i++) {
assert (*strp);
+
+ /* Don't let sv_setsv swipe, since our source array might
+ have multiple references to the same temp scalar (e.g.
+ from a list slice) */
+
ary[i] = newSV(0);
- sv_setsv(ary[i], *strp);
+ sv_setsv_flags(ary[i], *strp,
+ SV_GMAGIC|SV_DO_COW_SVSETSV|SV_NOSTEAL);
strp++;
}
}