[Matrix-SIG] Python crash when sort is given zero length

Charles G Waldman cgw@pgt.com
Tue, 15 Dec 1998 11:34:16 -0500 (EST)


list, take 2
In-Reply-To: <13942.35922.881228.950845@janus.pgt.com>
References: <199812141700.MAA17832@python.org>
	<3674509F.26638416@mayo.edu>
	<13942.35922.881228.950845@janus.pgt.com>
X-Mailer: VM 6.62 under 21.0 "Poitou60" XEmacs Lucid (beta60)

Charles G Waldman writes:

 > This was quite easy to fix.  Here's the (one-line) patch.

Oops, I attached the wrong file.  The patch I sent is bogus.  Sorry
about that!  Here's the right fix.

--- multiarraymodule.c.orig     Thu Aug 20 14:59:22 1998
+++ multiarraymodule.c  Tue Dec 15 11:27:08 1998
@@ -390,7 +390,7 @@
 
        elsize = ap->descr->elsize;
        m = ap->dimensions[ap->nd-1];
-       n = PyArray_SIZE(ap)/m;
+       n = (m==0) ? 0 : PyArray_SIZE(ap)/m;
        for (ip = ap->data, i=0; i<n; i++, ip+=elsize*m) {
                qsort(ip, m, elsize, compare_func);
        }