develooper Front page | perl.perl5.porters | Postings from January 2010

[perl #72334] Missing update of AvALLOC() in S_sortcv_stacked

Thread Next
Nicholas Clark
January 25, 2010 00:48
[perl #72334] Missing update of AvALLOC() in S_sortcv_stacked
Message ID:
# New Ticket Created by  Nicholas Clark 
# Please include the string:  [perl #72334]
# in the subject line of all future correspondence about this issue. 
# <URL: >

By code inspection, there is a bug in S_sortcv_stacked(), as it is not
assigning to AvALLOC() if it reallocates @_. I believe that it needs this
patch to fix it:

diff --git a/pp_sort.c b/pp_sort.c
index 12e77f9..0ef567c 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1790,6 +1790,7 @@ S_sortcv_stacked(pTHX_ SV *const a, SV *const b)
 	if (AvMAX(av) < 1) {
 	    AvMAX(av) = 1;
+	    AvALLOC(av) = ary;
 	    AvARRAY(av) = ary;

(compare with the analogous code in pp_ctl.c and pp_hot.c:

			if (items >= AvMAX(av) + 1) {
			    AvMAX(av) = items - 1;
			    AvALLOC(av) = ary;
			    AvARRAY(av) = ary;


No tests fail if I made the above change. However, I don't have a test case,
and I don't even know if it's possible to create one.

The bug seems to have existed since the code was added in 1999, originally
in pp_ctl.c:

Nicholas Clark

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About