summaryrefslogtreecommitdiffstats
path: root/Modules/cjkcodecs/multibytecodec.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/cjkcodecs/multibytecodec.c')
-rw-r--r--Modules/cjkcodecs/multibytecodec.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index dbd5314..95b2278 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -608,18 +608,24 @@ MultibyteCodec_Decode(MultibyteCodecObject *self,
MultibyteCodec_State state;
MultibyteDecodeBuffer buf;
PyObject *errorcb;
+ Py_buffer pdata;
const char *data, *errors = NULL;
Py_ssize_t datalen, finalsize;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|z:decode",
- codeckwarglist, &data, &datalen, &errors))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s*|z:decode",
+ codeckwarglist, &pdata, &errors))
return NULL;
+ data = pdata.buf;
+ datalen = pdata.len;
errorcb = internal_error_callback(errors);
- if (errorcb == NULL)
+ if (errorcb == NULL) {
+ PyBuffer_Release(&pdata);
return NULL;
+ }
if (datalen == 0) {
+ PyBuffer_Release(&pdata);
ERROR_DECREF(errorcb);
return make_tuple(PyUnicode_FromUnicode(NULL, 0), 0);
}
@@ -659,11 +665,13 @@ MultibyteCodec_Decode(MultibyteCodecObject *self,
if (PyUnicode_Resize(&buf.outobj, finalsize) == -1)
goto errorexit;
+ PyBuffer_Release(&pdata);
Py_XDECREF(buf.excobj);
ERROR_DECREF(errorcb);
return make_tuple(buf.outobj, datalen);
errorexit:
+ PyBuffer_Release(&pdata);
ERROR_DECREF(errorcb);
Py_XDECREF(buf.excobj);
Py_XDECREF(buf.outobj);