diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-05-10 10:01:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-10 10:01:00 (GMT) |
commit | d524802e9dd624f569948c4c0b6adbe000edcffe (patch) | |
tree | 4a7df1554ea38d328bd757ae91e59a89010ca164 /Objects | |
parent | b62cb5234be2f43833e52063bf32bff5b2cffc98 (diff) | |
download | cpython-d524802e9dd624f569948c4c0b6adbe000edcffe.zip cpython-d524802e9dd624f569948c4c0b6adbe000edcffe.tar.gz cpython-d524802e9dd624f569948c4c0b6adbe000edcffe.tar.bz2 |
Fix some missing null checks. (GH-118721)
(cherry picked from commit 7e6fcab20003b07621dc02ea78d6ea2fda500371)
Co-authored-by: Steve Dower <steve.dower@python.org>
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 4b144fa..b7c3fcf 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -6036,15 +6036,19 @@ object_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; } comma_w_quotes_sep = PyUnicode_FromString("', '"); + if (!comma_w_quotes_sep) { + Py_DECREF(sorted_methods); + return NULL; + } joined = PyUnicode_Join(comma_w_quotes_sep, sorted_methods); - method_count = PyObject_Length(sorted_methods); - Py_DECREF(sorted_methods); + Py_DECREF(comma_w_quotes_sep); if (joined == NULL) { - Py_DECREF(comma_w_quotes_sep); + 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; } @@ -6056,7 +6060,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); |