mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Fix some missing null checks. (GH-118721)
(cherry picked from commit 7e6fcab200
)
Co-authored-by: Steve Dower <steve.dower@python.org>
This commit is contained in:
parent
eb29e2f590
commit
8bfaf3a5f0
2 changed files with 15 additions and 7 deletions
|
@ -5470,15 +5470,19 @@ object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
return NULL;
|
||||
}
|
||||
comma_w_quotes_sep = PyUnicode_FromString("', '");
|
||||
joined = PyUnicode_Join(comma_w_quotes_sep, sorted_methods);
|
||||
method_count = PyObject_Length(sorted_methods);
|
||||
Py_DECREF(sorted_methods);
|
||||
if (joined == NULL) {
|
||||
Py_DECREF(comma_w_quotes_sep);
|
||||
if (!comma_w_quotes_sep) {
|
||||
Py_DECREF(sorted_methods);
|
||||
return NULL;
|
||||
}
|
||||
joined = PyUnicode_Join(comma_w_quotes_sep, sorted_methods);
|
||||
Py_DECREF(comma_w_quotes_sep);
|
||||
if (joined == NULL) {
|
||||
Py_DECREF(sorted_methods);
|
||||
return NULL;
|
||||
}
|
||||
method_count = PyObject_Length(sorted_methods);
|
||||
Py_DECREF(sorted_methods);
|
||||
if (method_count == -1) {
|
||||
Py_DECREF(comma_w_quotes_sep);
|
||||
Py_DECREF(joined);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -5490,7 +5494,6 @@ object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
method_count > 1 ? "s" : "",
|
||||
joined);
|
||||
Py_DECREF(joined);
|
||||
Py_DECREF(comma_w_quotes_sep);
|
||||
return NULL;
|
||||
}
|
||||
PyObject *obj = type->tp_alloc(type, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue