Skip to content

Commit 74c3d13

Browse files
committed
Check PyObject_CallFunctionObjArgs return value
1 parent 0740efb commit 74c3d13

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Objects/moduleobject.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,15 +869,16 @@ _Py_module_getattro(PyModuleObject *m, PyObject *name)
869869
static int
870870
module_setattro(PyModuleObject *mod, PyObject *name, PyObject *value)
871871
{
872+
PyObject *ret;
872873
assert(mod->md_dict != NULL);
873874
if (value == NULL) {
874875
PyObject *delattr = PyDict_GetItemWithError(mod->md_dict, &_Py_ID(__delattr__));
875876
if (PyErr_Occurred()) {
876877
return -1;
877878
}
878879
if (delattr) {
879-
PyObject_CallFunctionObjArgs(delattr, name, NULL);
880-
if (PyErr_Occurred()) {
880+
ret = PyObject_CallFunctionObjArgs(delattr, name, NULL);
881+
if (ret == NULL) {
881882
return -1;
882883
}
883884
return 0;
@@ -888,8 +889,8 @@ module_setattro(PyModuleObject *mod, PyObject *name, PyObject *value)
888889
return -1;
889890
}
890891
if (setattr) {
891-
PyObject_CallFunctionObjArgs(setattr, name, value, NULL);
892-
if (PyErr_Occurred()) {
892+
ret = PyObject_CallFunctionObjArgs(setattr, name, value, NULL);
893+
if (ret == NULL) {
893894
return -1;
894895
}
895896
return 0;

0 commit comments

Comments
 (0)