-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
gh-148222 Fix Null dereference bugs at genericaliasobject.c #148226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
c954f91
01faae2
eb56ccf
31b5522
e6a5d95
d7cccef
916a046
1defe5d
99b1ce9
b93f0bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| 1. Add Add NULL check and fallback to ga_vectorcall | ||
| 2. Add Null check to _Py_make_parameters when_PyTuple_Resize fails and parameter is null |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -242,7 +242,7 @@ _Py_make_parameters(PyObject *args) | |
| len += needed; | ||
| if (_PyTuple_Resize(¶meters, len) < 0) { | ||
| Py_DECREF(subparams); | ||
| Py_DECREF(parameters); | ||
| Py_XDECREF(parameters); | ||
| Py_XDECREF(tuple_args); | ||
| return NULL; | ||
| } | ||
|
|
@@ -650,7 +650,14 @@ ga_vectorcall(PyObject *self, PyObject *const *args, | |
| size_t nargsf, PyObject *kwnames) | ||
| { | ||
| gaobject *alias = (gaobject *) self; | ||
| PyObject *obj = PyVectorcall_Function(alias->origin)(alias->origin, args, nargsf, kwnames); | ||
| vectorcallfunc origin_vectorcall = PyVectorcall_Function(alias->origin); | ||
|
||
| PyObject *obj; | ||
| if (origin_vectorcall != NULL) { | ||
| obj = origin_vectorcall(alias->origin, args, nargsf, kwnames); | ||
| } else { | ||
| /* Fallback to generic call path*/ | ||
| obj = PyObject_Vectorcall(alias->origin, args, nargsf, kwnames); | ||
| } | ||
| return set_orig_class(obj, self); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently _PyTuple_Resize sets its arg to NULL on failures, so this will never be non-NULL. Possibly the only safe way to use _PyTuple_Resize is to keep another pointer to the tuple around and DECREF that on failure? I haven't verified in the code though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply remove this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
checked in
cpython/Objects/tupleobject.c
Line 1024 in 2c8f26c
removing the redundant
Py_XDECREFcall