https://github.com/python/cpython/commit/d524802e9dd624f569948c4c0b6adbe000edcffe
commit: d524802e9dd624f569948c4c0b6adbe000edcffe
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: zooba <[email protected]>
date: 2024-05-10T10:01:00Z
summary:

Fix some missing null checks. (GH-118721)

(cherry picked from commit 7e6fcab20003b07621dc02ea78d6ea2fda500371)

Co-authored-by: Steve Dower <[email protected]>

files:
M Objects/typeobject.c
M PC/launcher2.c

diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 4b144fab5de8f1..b7c3fcf47f23fc 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);
diff --git a/PC/launcher2.c b/PC/launcher2.c
index 139aa61bbe5cc2..98231613efb26f 100644
--- a/PC/launcher2.c
+++ b/PC/launcher2.c
@@ -2707,6 +2707,11 @@ process(int argc, wchar_t ** argv)
     DWORD len = GetEnvironmentVariableW(L"PYLAUNCHER_LIMIT_TO_COMPANY", NULL, 
0);
     if (len > 1) {
         wchar_t *limitToCompany = allocSearchInfoBuffer(&search, len);
+        if (!limitToCompany) {
+            exitCode = RC_NO_MEMORY;
+            winerror(0, L"Failed to allocate internal buffer");
+            goto abort;
+        }
         search.limitToCompany = limitToCompany;
         if (0 == GetEnvironmentVariableW(L"PYLAUNCHER_LIMIT_TO_COMPANY", 
limitToCompany, len)) {
             exitCode = RC_INTERNAL_ERROR;

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to