8000 Fix some missing null checks. (GH-118721) · python/cpython@8bfaf3a · GitHub
[go: up one dir, main page]

Skip to content

Commit 8bfaf3a

Browse files
Fix some missing null checks. (GH-118721)
(cherry picked from commit 7e6fcab) Co-authored-by: Steve Dower <steve.dower@python.org>
1 parent eb29e2f commit 8bfaf3a

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Objects/typeobject.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5470,15 +5470,19 @@ object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
54705470
return NULL;
54715471
}
54725472
comma_w_quotes_sep = PyUnicode_FromString("', '");
5473+
if (!comma_w_quotes_sep) {
5474+
Py_DECREF(sorted_methods);
5475+
return NULL;
5476+
}
54735477
joined = PyUnicode_Join(comma_w_quotes_sep, sorted_methods);
5474-
method_count = PyObject_Length(sorted_methods);
5475-
Py_DECREF(sorted_methods);
5478+
Py_DECREF(comma_w_quotes_sep);
54765479
if (joined == NULL) {
5477-
Py_DECREF(comma_w_quotes_sep);
5480+
Py_DECREF(sorted_methods);
54785481
return NULL;
54795482
}
5483+
method_count = PyObject_Length(sorted_methods);
5484+
Py_DECREF(sorted_methods);
54805485
if (method_count == -1) {
5481-
Py_DECREF(comma_w_quotes_sep);
54825486
Py_DECREF(joined);
54835487
return NULL;
54845488
}
@@ -5490,7 +5494,6 @@ object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
54905494
method_count > 1 ? "s" : "",
54915495
joined);
54925496
Py_DECREF(joined);
5493-
Py_DECREF(comma_w_quotes_sep);
54945497
return NULL;
54955498
}
54965499
PyObject *obj = type->tp_alloc(type, 0);

PC/launcher2.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2681,6 +2681,11 @@ process(int argc, wchar_t ** argv)
26812681
DWORD len = GetEnvironmentVariableW(L"PYLAUNCHER_LIMIT_TO_COMPANY", NULL, 0);
26822682
if (len > 1) {
26832683
wchar_t *limitToCompany = allocSearchInfoBuffer(&search, len);
2684+
if (!limitToCompany) {
2685+
exitCode = RC_NO_MEMORY;
2686+
winerror(0, L"Failed to allocate internal buffer");
2687+
goto abort;
2688+
}
26842689
search.limitToCompany = limitToCompany;
26852690
if (0 == GetEnvironmentVariableW(L"PYLAUNCHER_LIMIT_TO_COMPANY", limitToCompany, len)) {
26862691
exitCode = RC_INTERNAL_ERROR;

0 commit comments

Comments
 (0)
0