From 9a80faba886ab081e7ccb30440f3c8e158738bab Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 21 Nov 2011 02:50:14 +0100 Subject: MultibyteCodec_Encode() checks if PyUnicode_AS_UNICODE() failed --- Modules/cjkcodecs/multibytecodec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index 77edbb3..6b23523 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -574,8 +574,11 @@ MultibyteCodec_Encode(MultibyteCodecObject *self, } } - data = PyUnicode_AS_UNICODE(arg); - datalen = PyUnicode_GET_SIZE(arg); + data = PyUnicode_AsUnicodeAndSize(arg, &datalen); + if (data == NULL) { + Py_XDECREF(ucvt); + return NULL; + } errorcb = internal_error_callback(errors); if (errorcb == NULL) { -- cgit v0.12