8000 BUG: Do not segfault on dot between sparse matrices. · numpy/numpy@eb46577 · GitHub
[go: up one dir, main page]

Skip to content

Commit eb46577

Browse files
stefanvcharris
authored andcommitted
BUG: Do not segfault on dot between sparse matrices.
1 parent 04d225a commit eb46577

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

numpy/core/src/multiarray/multiarraymodule.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,12 +945,16 @@ PyArray_MatrixProduct2(PyObject *op1, PyObject *op2, PyArrayObject* out)
945945
char *op;
946946
npy_intp dimensions[NPY_MAXDIMS];
947947
PyArray_DotFunc *dot;
948-
PyArray_Descr *typec;
948+
PyArray_Descr *typec = NULL;
949949
NPY_BEGIN_THREADS_DEF;
950950

951951
typenum = PyArray_ObjectType(op1, 0);
952952
typenum = PyArray_ObjectType(op2, typenum);
953953
typec = PyArray_DescrFromType(typenum);
954+
if (typec == NULL) {
955+
PyErr_SetString(PyExc_ValueError, "Cannot find a common data type.");
956+
return NULL;
957+
}
954958

955959
Py_INCREF(typec);
956960
ap1 = (PyArrayObject *)PyArray_FromAny(op1, typec, 0, 0,

0 commit comments

Comments
 (0)
0