mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
* Fix the refcount leak in _PySequence_BytesToCharpArray from r78946.
* Also fixes a potential extra DECREF of an arg in the error case within _posixsubprocess.fork_exec() by not reusing the process_args variable.
This commit is contained in:
parent
845085703c
commit
68f52178d9
2 changed files with 13 additions and 8 deletions
|
|
@ -2737,6 +2737,7 @@ _PySequence_BytesToCharpArray(PyObject* self)
|
|||
{
|
||||
char **array;
|
||||
Py_ssize_t i, argc;
|
||||
PyObject *item = NULL;
|
||||
|
||||
argc = PySequence_Size(self);
|
||||
if (argc == -1)
|
||||
|
|
@ -2749,7 +2750,7 @@ _PySequence_BytesToCharpArray(PyObject* self)
|
|||
}
|
||||
for (i = 0; i < argc; ++i) {
|
||||
char *data;
|
||||
PyObject *item = PySequence_GetItem(self, i);
|
||||
item = PySequence_GetItem(self, i);
|
||||
data = PyBytes_AsString(item);
|
||||
if (data == NULL) {
|
||||
/* NULL terminate before freeing. */
|
||||
|
|
@ -2761,12 +2762,14 @@ _PySequence_BytesToCharpArray(PyObject* self)
|
|||
PyErr_NoMemory();
|
||||
goto fail;
|
||||
}
|
||||
Py_DECREF(item);
|
||||
}
|
||||
array[argc] = NULL;
|
||||
|
||||
return array;
|
||||
|
||||
fail:
|
||||
Py_XDECREF(item);
|
||||
_Py_FreeCharPArray(array);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue