summaryrefslogtreecommitdiff
path: root/pp_sort.c
diff options
context:
space:
mode:
Diffstat (limited to 'pp_sort.c')
-rw-r--r--pp_sort.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/pp_sort.c b/pp_sort.c
index 0c5efb0869..4f81aaab7e 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1067,7 +1067,8 @@ PP(pp_sort)
for (i = 0; i < max; i++)
base[i] = newSVsv(base[i]);
av_clear(av);
- av_extend(av, max);
+ if (max)
+ av_extend(av, max-1);
for (i=0; i < max; i++) {
SV * const sv = base[i];
SV ** const didstore = av_store(av, i, sv);
@@ -1094,7 +1095,7 @@ PP(pp_sort)
}
av_clear(av);
if (max > 0) {
- av_extend(av, max);
+ av_extend(av, max-1);
Copy(base, AvARRAY(av), max, SV*);
}
AvFILLp(av) = max - 1;