mirror of
https://github.com/python/cpython.git
synced 2025-11-18 01:57:37 +00:00
Fix refleak introduced by #10812.
This commit is contained in:
parent
952c0782b3
commit
9ad63e0914
1 changed files with 22 additions and 13 deletions
|
|
@ -3827,16 +3827,19 @@ parse_arglist(PyObject* argv, Py_ssize_t *argc)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
for (i = 0; i < *argc; i++) {
|
for (i = 0; i < *argc; i++) {
|
||||||
if (!fsconvert_strdup(PySequence_ITEM(argv, i),
|
PyObject* item = PySequence_ITEM(argv, i);
|
||||||
&argvlist[i]))
|
if (item == NULL)
|
||||||
{
|
goto fail;
|
||||||
*argc = i;
|
if (!fsconvert_strdup(item, &argvlist[i])) {
|
||||||
|
Py_DECREF(item);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
Py_DECREF(item);
|
||||||
}
|
}
|
||||||
argvlist[*argc] = NULL;
|
argvlist[*argc] = NULL;
|
||||||
return argvlist;
|
return argvlist;
|
||||||
fail:
|
fail:
|
||||||
|
*argc = i;
|
||||||
free_string_array(argvlist, *argc);
|
free_string_array(argvlist, *argc);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -6177,22 +6180,28 @@ iov_setup(struct iovec **iov, Py_buffer **buf, PyObject *seq, int cnt, int type)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < cnt; i++) {
|
for (i = 0; i < cnt; i++) {
|
||||||
if (PyObject_GetBuffer(PySequence_GetItem(seq, i),
|
PyObject *item = PySequence_GetItem(seq, i);
|
||||||
&(*buf)[i], type) == -1) {
|
if (item == NULL)
|
||||||
PyMem_Del(*iov);
|
goto fail;
|
||||||
for (j = 0; j < i; j++) {
|
if (PyObject_GetBuffer(item, &(*buf)[i], type) == -1) {
|
||||||
PyBuffer_Release(&(*buf)[j]);
|
Py_DECREF(item);
|
||||||
}
|
goto fail;
|
||||||
PyMem_Del(*buf);
|
|
||||||
total = 0;
|
|
||||||
return total;
|
|
||||||
}
|
}
|
||||||
|
Py_DECREF(item);
|
||||||
(*iov)[i].iov_base = (*buf)[i].buf;
|
(*iov)[i].iov_base = (*buf)[i].buf;
|
||||||
blen = (*buf)[i].len;
|
blen = (*buf)[i].len;
|
||||||
(*iov)[i].iov_len = blen;
|
(*iov)[i].iov_len = blen;
|
||||||
total += blen;
|
total += blen;
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
PyMem_Del(*iov);
|
||||||
|
for (j = 0; j < i; j++) {
|
||||||
|
PyBuffer_Release(&(*buf)[j]);
|
||||||
|
}
|
||||||
|
PyMem_Del(*buf);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue