[Matrix-SIG] Python crash when sort is given zero length list
Charles G Waldman
cgw@pgt.com
Tue, 15 Dec 1998 11:20:34 -0500 (EST)
Travis E. Oliphant writes:
> >>> from Numeric import sort
> >>> sort([])
> Floating point exception
This was quite easy to fix. Here's the (one-line) patch.
--- multiarraymodule.c.orig Thu Aug 20 14:59:22 1998
+++ multiarraymodule.c Tue Dec 15 11:17:11 1998
@@ -390,6 +390,7 @@
elsize = ap->descr->elsize;
m = ap->dimensions[ap->nd-1];
+ if (m==0) goto fail;
n = PyArray_SIZE(ap)/m;
for (ip = ap->data, i=0; i<n; i++, ip+=elsize*m) {
qsort(ip, m, elsize, compare_func);