diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2013-03-18 15:44:12 +0100 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2013-03-18 15:50:45 +0100 |
commit | 793e83d06b2c23cdfe9a1b3abc5e16eeab3203c9 (patch) | |
tree | b71c0e7054400737b1eae2e49d50ac6f8fe1fabd | |
parent | 12dce71414f546bdad87bf8eb2a7f802e315b235 (diff) | |
download | numpy-793e83d06b2c23cdfe9a1b3abc5e16eeab3203c9.tar.gz |
BUG: no buffer reuse in nditer, if there was no buffer previously
If the buffer is used or not can possible change during iteration.
In this case, the buffer cannot be reused if it never existed...
-rw-r--r-- | numpy/core/src/multiarray/nditer_api.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/nditer_api.c b/numpy/core/src/multiarray/nditer_api.c index 7d468a811..eef7815af 100644 --- a/numpy/core/src/multiarray/nditer_api.c +++ b/numpy/core/src/multiarray/nditer_api.c @@ -2192,6 +2192,11 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) break; /* Just a copy */ case 0: + /* Do not reuse buffer if it did not exist */ + if (!(op_itflags[iop] & NPY_OP_ITFLAG_USINGBUFFER) && + (prev_dataptrs != NULL)) { + prev_dataptrs[iop] = NULL; + } /* * No copyswap or cast was requested, so all we're * doing is copying the data to fill the buffer and @@ -2235,6 +2240,11 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) break; /* Just a copy, but with a reduction */ case NPY_OP_ITFLAG_REDUCE: + /* Do not reuse buffer if it did not exist */ + if (!(op_itflags[iop] & NPY_OP_ITFLAG_USINGBUFFER) && + (prev_dataptrs != NULL)) { + prev_dataptrs[iop] = NULL; + } if (ad_strides[iop] == 0) { strides[iop] = 0; /* It's all in one stride in the inner loop dimension */ |