blob: 5ee260a4b4bdab4d46ebc9448b65b4d61e716e10 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
--- sv.c
+++ sv.c
@@ -10421,7 +10421,8 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param)
IoBOTTOM_NAME(dstr) = SAVEPV(IoBOTTOM_NAME(dstr));
break;
case SVt_PVAV:
- if (AvARRAY((AV*)sstr)) {
+ /* avoid cloning an empty array */
+ if (AvARRAY((AV *)sstr) && AvFILLp((AV *)sstr) >= 0) {
SV **dst_ary, **src_ary;
SSize_t items = AvFILLp((AV*)sstr) + 1;
@@ -10446,6 +10447,8 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param)
else {
AvARRAY((AV*)dstr) = NULL;
AvALLOC((AV*)dstr) = (SV**)NULL;
+ AvMAX( (AV *)dstr) = -1;
+ AvFILLp((AV *)dstr) = -1;
}
break;
case SVt_PVHV:
|