* 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.
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 952ad40..cd5a9fd 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2737,6 +2737,7 @@
{
char **array;
Py_ssize_t i, argc;
+ PyObject *item = NULL;
argc = PySequence_Size(self);
if (argc == -1)
@@ -2749,7 +2750,7 @@
}
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 @@
PyErr_NoMemory();
goto fail;
}
+ Py_DECREF(item);
}
array[argc] = NULL;
return array;
fail:
+ Py_XDECREF(item);
_Py_FreeCharPArray(array);
return NULL;
}