Skip to content

bpo-42034:Fixed unchecked return in Objects/typeobject.c #22695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix unchecked return in Objects/typeobject.c. The return value of a function that is potentially used to initialize a local variable is not checked. Therefore, reading the local variable may result in undefined behavior.
17 changes: 9 additions & 8 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,14 +823,15 @@ type_set_bases(PyTypeObject *type, PyObject *new_bases, void *context)
PyTypeObject *cls;
PyObject *new_mro, *old_mro = NULL;

PyArg_UnpackTuple(PyList_GET_ITEM(temp, i),
"", 2, 3, &cls, &new_mro, &old_mro);
/* Do not rollback if cls has a newer version of MRO. */
if (cls->tp_mro == new_mro) {
Py_XINCREF(old_mro);
cls->tp_mro = old_mro;
Py_DECREF(new_mro);
}
if(PyArg_UnpackTuple(PyList_GET_ITEM(temp, i),
"", 2, 3, &cls, &new_mro, &old_mro)) {
/* Do not rollback if cls has a newer version of MRO. */
if (cls->tp_mro == new_mro) {
Py_XINCREF(old_mro);
cls->tp_mro = old_mro;
Py_DECREF(new_mro);
}
}
}
Py_DECREF(temp);

Expand Down