summaryrefslogtreecommitdiff
path: root/lang/perl5.14/files/patch-bug54758
blob: a969568a7e104211abd24b0ea6d0a2f1745f8f7f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# http://rt.perl.org/rt3/Public/Bug/Display.html?id=54758
# http://perl5.git.perl.org/perl.git/commitdiff/62b40d2474e7487e6909e1872b6bccdf812c6818?hp=d49025b75d9b5002071bd1a4210654dab5663ef0#patch1
diff --git a/pp_sort.c b/pp_sort.c
index 9fe0dad..edfdadf 100644
--- pp_sort.c
+++ pp_sort.c
@@ -1557,11 +1557,12 @@ PP(pp_sort)
 	max = AvFILL(av) + 1;
 	if (SvMAGICAL(av)) {
 	    MEXTEND(SP, max);
-	    p2 = SP;
 	    for (i=0; i < max; i++) {
 		SV **svp = av_fetch(av, i, FALSE);
 		*SP++ = (svp) ? *svp : NULL;
 	    }
+	    SP--;
+	    p1 = p2 = SP - (max-1);
 	}
 	else {
 	    if (SvREADONLY(av))
@@ -1717,7 +1718,7 @@ PP(pp_sort)
 	SvREADONLY_off(av);
     else if (av && !sorting_av) {
 	/* simulate pp_aassign of tied AV */
-	SV** const base = ORIGMARK+1;
+	SV** const base = MARK+1;
 	for (i=0; i < max; i++) {
 	    base[i] = newSVsv(base[i]);
 	}