summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2008-07-08 17:02:15 +0000
committerTravis Oliphant <oliphant@enthought.com>2008-07-08 17:02:15 +0000
commitebf8dce3a385f9da5b1e769cb1c41f8f928dfedf (patch)
tree9f8008729c3d910f86b593aac7499db55245ea9f
parent048bc867ad2ba31dbd784eb6432a492a65686510 (diff)
downloadnumpy-ebf8dce3a385f9da5b1e769cb1c41f8f928dfedf.tar.gz
Fix ref-count leak in Ticket #843
-rw-r--r--numpy/core/src/multiarraymodule.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/numpy/core/src/multiarraymodule.c b/numpy/core/src/multiarraymodule.c
index 1b752d653..dc28fbf37 100644
--- a/numpy/core/src/multiarraymodule.c
+++ b/numpy/core/src/multiarraymodule.c
@@ -2139,12 +2139,18 @@ PyArray_CanCoerceScalar(int thistype, int neededtype,
if (scalar == PyArray_NOSCALAR) {
return PyArray_CanCastSafely(thistype, neededtype);
}
+
from = PyArray_DescrFromType(thistype);
if (from->f->cancastscalarkindto &&
(castlist = from->f->cancastscalarkindto[scalar])) {
while (*castlist != PyArray_NOTYPE)
- if (*castlist++ == neededtype) return 1;
+ if (*castlist++ == neededtype) {
+ Py_DECREF(from);
+ return 1;
+ }
}
+ Py_DECREF(from);
+
switch(scalar) {
case PyArray_BOOL_SCALAR:
case PyArray_OBJECT_SCALAR: