diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-04-14 18:11:41 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-04-14 18:11:41 +0200 |
commit | 1ee5428618bc73ee50bafb9286143e0c1411ca58 (patch) | |
tree | c8833cb8ad9829876a52ac5e18f08795f9dce89b /Modules/cjkcodecs | |
parent | 41331a2ad7e17c984bda69dc824e48bdd5196e63 (diff) | |
download | cpython-1ee5428618bc73ee50bafb9286143e0c1411ca58.tar.gz |
Issue #17693: Fix memory/reference leaks
Diffstat (limited to 'Modules/cjkcodecs')
-rw-r--r-- | Modules/cjkcodecs/multibytecodec.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index 5a916fd962..4c865eca11 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -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; } |