From 93f474613fd4896ef2f5e44fe50e4f7cee141164 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Jan 2015 13:09:23 -0600 Subject: [PATCH] PyErr_NoMemory when PyArray_Zeros fails to initialize --- numpy/fft/fftpack_litemodule.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/numpy/fft/fftpack_litemodule.c b/numpy/fft/fftpack_litemodule.c index 7b37ce9b775e..99c582ea9e5b 100644 --- a/numpy/fft/fftpack_litemodule.c +++ b/numpy/fft/fftpack_litemodule.c @@ -149,7 +149,7 @@ fftpack_rfftf(PyObject *NPY_UNUSED(self), PyObject *args) PyObject *op1, *op2; PyArrayObject *data, *ret; PyArray_Descr *descr; - double *wsave, *dptr, *rptr; + double *wsave = NULL, *dptr, *rptr; npy_intp nsave; int npts, nrepeats, i, rstep; @@ -166,6 +166,10 @@ fftpack_rfftf(PyObject *NPY_UNUSED(self), PyObject *args) PyArray_DIMS(data)[PyArray_NDIM(data) - 1] = npts/2 + 1; ret = (PyArrayObject *)PyArray_Zeros(PyArray_NDIM(data), PyArray_DIMS(data), PyArray_DescrFromType(NPY_CDOUBLE), 0); + if (ret == NULL) { + PyErr_NoMemory(); + goto fail; + } PyArray_DIMS(data)[PyArray_NDIM(data) - 1] = npts; rstep = PyArray_DIM(ret, PyArray_NDIM(ret) - 1)*2;