mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
[3.11] gh-99240: Reset pointer to NULL when the pointed memory is freed in argument parsing (GH-99890) (#100385)
(cherry picked from commit efbb1eb9f5
)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
parent
bee905184e
commit
bed1d141a9
4 changed files with 31 additions and 5 deletions
|
@ -202,9 +202,9 @@ _PyArg_VaParse_SizeT(PyObject *args, const char *format, va_list va)
|
|||
static int
|
||||
cleanup_ptr(PyObject *self, void *ptr)
|
||||
{
|
||||
if (ptr) {
|
||||
PyMem_Free(ptr);
|
||||
}
|
||||
void **pptr = (void **)ptr;
|
||||
PyMem_Free(*pptr);
|
||||
*pptr = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1169,7 +1169,7 @@ _Py_COMP_DIAG_POP
|
|||
PyErr_NoMemory();
|
||||
RETURN_ERR_OCCURRED;
|
||||
}
|
||||
if (addcleanup(*buffer, freelist, cleanup_ptr)) {
|
||||
if (addcleanup(buffer, freelist, cleanup_ptr)) {
|
||||
Py_DECREF(s);
|
||||
return converterr(
|
||||
"(cleanup problem)",
|
||||
|
@ -1215,7 +1215,7 @@ _Py_COMP_DIAG_POP
|
|||
PyErr_NoMemory();
|
||||
RETURN_ERR_OCCURRED;
|
||||
}
|
||||
if (addcleanup(*buffer, freelist, cleanup_ptr)) {
|
||||
if (addcleanup(buffer, freelist, cleanup_ptr)) {
|
||||
Py_DECREF(s);
|
||||
return converterr("(cleanup problem)",
|
||||
arg, msgbuf, bufsize);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue