Skip to content

Fix segfault when PyArray_VOID and no minitype in _array_find_type. #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ _array_find_type(PyObject *op, PyArray_Descr *minitype, int max)
* unless input was already a VOID
*/
if (outtype->type_num == PyArray_VOID &&
minitype->type_num != PyArray_VOID) {
(minitype == NULL || minitype->type_num != PyArray_VOID)) {
Py_DECREF(outtype);
return PyArray_DescrFromType(PyArray_OBJECT);
}
Expand Down
4 changes: 4 additions & 0 deletions numpy/core/tests/test_multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ def test_from_string(self) :
msg = 'String conversion for %s' % type
assert_equal(array(nstr, dtype=type), result, err_msg=msg)

def test_void(self):
arr = np.array([np.void(0)], dtype='V')
assert_equal(arr.dtype.kind, 'V')

def test_non_sequence_sequence(self):
"""Should not segfault.

Expand Down