Skip to content

Commit bdb5cc7

Browse files
authored
Merge pull request numpy#19409 from defoishugo/fix_ufunc_object_leaks
BUG: fix some memory leaks in ufunc_object
2 parents 3300c03 + 4b97141 commit bdb5cc7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

numpy/core/src/umath/ufunc_object.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5228,6 +5228,7 @@ PyUFunc_RegisterLoopForDescr(PyUFuncObject *ufunc,
52285228

52295229
arg_typenums = PyArray_malloc(ufunc->nargs * sizeof(int));
52305230
if (arg_typenums == NULL) {
5231+
Py_DECREF(key);
52315232
PyErr_NoMemory();
52325233
return -1;
52335234
}
@@ -5365,6 +5366,7 @@ PyUFunc_RegisterLoopForType(PyUFuncObject *ufunc,
53655366
/* Get entry for this user-defined type*/
53665367
cobj = PyDict_GetItemWithError(ufunc->userloops, key);
53675368
if (cobj == NULL && PyErr_Occurred()) {
5369+
Py_DECREF(key);
53685370
return 0;
53695371
}
53705372
/* If it's not there, then make one and return. */

0 commit comments

Comments
 (0)