summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c5
1 files changed, 4 insertions, 1 deletions
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 @@ _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;
}