[Matrix-SIG] SegFault?
Travis Oliphant
Oliphant.Travis@mayo.edu
Fri, 16 Apr 1999 10:55:38 -0500 (CDT)
The segfault mentioned previously happens whenever the second argument to
array is not a string. This is because the output from
PyString_AsString(tpo) in array_array() in multiarraymodule.c does not
check for a NULL return.
Forgot to mention. My system is:
Python 1.5.2b2 (#1, Mar 9 1999, 17:40:28) [GCC 2.7.2.3] on linux2
running LLNLDistribution11
I think the problem is that call to PyString_AsString does not
check conversion does not check to see if NULL is returned before
dereferencing the result.
Here is the patch to fix it:
*** multiarraymodule.c Fri Apr 16 10:53:58 1999
--- multiarraymodule.c.orig Fri Apr 16 10:52:18 1999
***************
*** 865,872 ****
type = PyArray_NOTYPE;
} else {
tp = PyString_AsString(tpo);
! if (tp == NULL) type = PyArray_NOTYPE;
! else if (tp[0] == 0) type = PyArray_NOTYPE;
else type = tp[0];
}
--- 865,871 ----
type = PyArray_NOTYPE;
} else {
tp = PyString_AsString(tpo);
! if (tp[0] == 0) type = PyArray_NOTYPE;
else type = tp[0];
}