Skip to content

Commit 60fb218

Browse files
committed
Check ufunc's dict on creation
1 parent 058ea0f commit 60fb218

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

numpy/_core/src/umath/ufunc_object.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4687,6 +4687,7 @@ PyUFunc_FromFuncAndDataAndSignatureAndIdentity(PyUFuncGenericFunction *func, voi
46874687
ufunc->core_signature = NULL;
46884688
ufunc->core_enabled = 0;
46894689
ufunc->obj = NULL;
4690+
ufunc->dict = NULL;
46904691
ufunc->core_num_dims = NULL;
46914692
ufunc->core_num_dim_ix = 0;
46924693
ufunc->core_offsets = NULL;
@@ -4772,6 +4773,10 @@ PyUFunc_FromFuncAndDataAndSignatureAndIdentity(PyUFuncGenericFunction *func, voi
47724773
}
47734774
}
47744775
ufunc->dict = PyDict_New();
4776+
if (ufunc->dict == NULL) {
4777+
Py_DECREF(ufunc);
4778+
return NULL;
4779+
}
47754780
/*
47764781
* TODO: I tried adding a default promoter here (either all object for
47774782
* some special cases, or all homogeneous). Those are reasonable

0 commit comments

Comments
 (0)