Skip to content

Commit

Permalink
Fix some missing null checks. (pythonGH-118721)
Browse files Browse the repository at this point in the history
  • Loading branch information
zooba authored May 10, 2024
1 parent 17a2cc1 commit 7e6fcab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions PC/launcher2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7e6fcab

Please sign in to comment.