From 8fbc465f2c13fc29fb1dc945df3440f8e60f8ec7 Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Fri, 21 Mar 2014 16:41:09 -0400 Subject: BUG: fix broken operand initialization for einsum. Closes #4528. --- numpy/core/src/multiarray/multiarraymodule.c | 2 +- numpy/core/tests/test_einsum.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c index a4c5840bf..efaf1152f 100644 --- a/numpy/core/src/multiarray/multiarraymodule.c +++ b/numpy/core/src/multiarray/multiarraymodule.c @@ -2273,7 +2273,7 @@ einsum_sub_op_from_lists(PyObject *args, /* Set the operands to NULL */ for (i = 0; i < nop; ++i) { - op[nop] = NULL; + op[i] = NULL; } /* Get the operands and build the subscript string */ diff --git a/numpy/core/tests/test_einsum.py b/numpy/core/tests/test_einsum.py index 2e57794a0..555300bbb 100644 --- a/numpy/core/tests/test_einsum.py +++ b/numpy/core/tests/test_einsum.py @@ -31,6 +31,9 @@ class TestEinSum(TestCase): # other keyword arguments are rejected assert_raises(TypeError, np.einsum, "", 0, bad_arg=0) + # issue 4528 revealed a segfault with this call + assert_raises(TypeError, np.einsum, *(None,)*63) + # number of operands must match count in subscripts string assert_raises(ValueError, np.einsum, "", 0, 0) assert_raises(ValueError, np.einsum, ",", 0, [0], [0]) -- cgit v1.2.1