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:
Miss Islington (bot) 2024-05-10 11:51:57 +02:00 committed by GitHub
parent eb29e2f590
commit 8bfaf3a5f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 7 deletions

View file

@ -5470,15 +5470,19 @@ object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL; return NULL;
} }
comma_w_quotes_sep = PyUnicode_FromString("', '"); comma_w_quotes_sep = PyUnicode_FromString("', '");
joined = PyUnicode_Join(comma_w_quotes_sep, sorted_methods); if (!comma_w_quotes_sep) {
method_count = PyObject_Length(sorted_methods);
Py_DECREF(sorted_methods); Py_DECREF(sorted_methods);
if (joined == NULL) {
Py_DECREF(comma_w_quotes_sep);
return NULL; return NULL;
} }
if (method_count == -1) { joined = PyUnicode_Join(comma_w_quotes_sep, sorted_methods);
Py_DECREF(comma_w_quotes_sep); 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(joined); Py_DECREF(joined);
return NULL; return NULL;
} }
@ -5490,7 +5494,6 @@ object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
method_count > 1 ? "s" : "", method_count > 1 ? "s" : "",
joined); joined);
Py_DECREF(joined); Py_DECREF(joined);
Py_DECREF(comma_w_quotes_sep);
return NULL; return NULL;
} }
PyObject *obj = type->tp_alloc(type, 0); PyObject *obj = type->tp_alloc(type, 0);

View file

@ -2681,6 +2681,11 @@ process(int argc, wchar_t ** argv)
DWORD len = GetEnvironmentVariableW(L"PYLAUNCHER_LIMIT_TO_COMPANY", NULL, 0); DWORD len = GetEnvironmentVariableW(L"PYLAUNCHER_LIMIT_TO_COMPANY", NULL, 0);
if (len > 1) { if (len > 1) {
wchar_t *limitToCompany = allocSearchInfoBuffer(&search, len); 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; search.limitToCompany = limitToCompany;
if (0 == GetEnvironmentVariableW(L"PYLAUNCHER_LIMIT_TO_COMPANY", limitToCompany, len)) { if (0 == GetEnvironmentVariableW(L"PYLAUNCHER_LIMIT_TO_COMPANY", limitToCompany, len)) {
exitCode = RC_INTERNAL_ERROR; exitCode = RC_INTERNAL_ERROR;