mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
Issue #17693: Fix memory/reference leaks
This commit is contained in:
parent
bf71f7d654
commit
322cc7438c
1 changed files with 3 additions and 5 deletions
|
@ -738,7 +738,6 @@ encoder_encode_stateful(MultibyteStatefulEncoderContext *ctx,
|
|||
PyObject *inbuf = NULL;
|
||||
Py_ssize_t inpos, datalen;
|
||||
PyObject *origpending = NULL;
|
||||
wchar_t *data;
|
||||
|
||||
if (PyUnicode_Check(unistr))
|
||||
ucvt = NULL;
|
||||
|
@ -754,10 +753,6 @@ encoder_encode_stateful(MultibyteStatefulEncoderContext *ctx,
|
|||
}
|
||||
}
|
||||
|
||||
data = PyUnicode_AsUnicodeAndSize(unistr, &datalen);
|
||||
if (data == NULL)
|
||||
goto errorexit;
|
||||
|
||||
if (ctx->pending) {
|
||||
PyObject *inbuf_tmp;
|
||||
|
||||
|
@ -793,6 +788,7 @@ encoder_encode_stateful(MultibyteStatefulEncoderContext *ctx,
|
|||
origpending = NULL;
|
||||
goto errorexit;
|
||||
}
|
||||
Py_XDECREF(origpending);
|
||||
|
||||
if (inpos < datalen) {
|
||||
if (datalen - inpos > MAXENCPENDING) {
|
||||
|
@ -808,6 +804,7 @@ encoder_encode_stateful(MultibyteStatefulEncoderContext *ctx,
|
|||
}
|
||||
}
|
||||
|
||||
Py_DECREF(inbuf);
|
||||
Py_XDECREF(ucvt);
|
||||
return r;
|
||||
|
||||
|
@ -815,6 +812,7 @@ errorexit:
|
|||
Py_XDECREF(r);
|
||||
Py_XDECREF(ucvt);
|
||||
Py_XDECREF(origpending);
|
||||
Py_XDECREF(inbuf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue