[Matrix-SIG] SegFault?

Charles G Waldman cgw@fnal.gov
Fri, 16 Apr 1999 11:07:08 -0500 (CDT)


Travis Oliphant writes:
 > 
 > Does anybody else get a segfault when running:
 > 
 > >>> array(<anything>,0)

Yes, it's reproducible.  Due to a lack of sufficient type-checking in
the C code.
 > 
 > I know this is an incorrect calling sequence, I typed it in by mistake.

It's desirable that *no* incorrect calls generate segfaults!

Here's a patch:


--- Src/multiarraymodule.c	1999/04/16 15:53:26	1.1
+++ Src/multiarraymodule.c	1999/04/16 16:03:49
@@ -863,6 +863,10 @@
 	if (tpo == Py_None) {
 		type = PyArray_NOTYPE;
 	} else {
+		if (!PyString_Check(tpo)){
+			PyErr_SetString(PyExc_TypeError, "Invalid type for array");
+			return NULL;
+		}
 		tp = PyString_AsString(tpo);
 		if (tp[0] == 0) type = PyArray_NOTYPE;
 		else type = tp[0];