diff options
author | Bo Borgerson <gigabo@gmail.com> | 2009-11-02 11:25:23 -0600 |
---|---|---|
committer | Steve Peters <steve@fisharerojo.org> | 2009-11-02 11:25:23 -0600 |
commit | 2b6765935f5ee68d8093e686b8e292ad5de5a898 (patch) | |
tree | 383624ed8bb748573fcffe09f9486f20c4818ace /av.c | |
parent | 2f7a9718549bed20690a376daf82104fa475c252 (diff) | |
download | perl-2b6765935f5ee68d8093e686b8e292ad5de5a898.tar.gz |
[PATCH] [perl #20321] Non-destructive Perl_av_make
Don't let sv_setsv swipe temps in av_make, since the source array
might have multiple references to the same temp scalar (e.g. from
a list slice).
Diffstat (limited to 'av.c')
-rw-r--r-- | av.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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++; } } |