From e21262ca9e286aee27741eb8bb69508a911ec10b Mon Sep 17 00:00:00 2001 From: Mark Hammond Date: Thu, 18 Jul 2002 23:06:17 +0000 Subject: Fix bug [ 549731 ] Unicode encoders appears to leak references. Python 2.2.1 bugfix candidate. --- Python/codecs.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Python/codecs.c b/Python/codecs.c index 3324b80..3e54d8f 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -271,6 +271,7 @@ PyObject *PyCodec_Encoder(const char *encoding) if (codecs == NULL) goto onError; v = PyTuple_GET_ITEM(codecs,0); + Py_DECREF(codecs); Py_INCREF(v); return v; @@ -287,6 +288,7 @@ PyObject *PyCodec_Decoder(const char *encoding) if (codecs == NULL) goto onError; v = PyTuple_GET_ITEM(codecs,1); + Py_DECREF(codecs); Py_INCREF(v); return v; @@ -298,12 +300,14 @@ PyObject *PyCodec_StreamReader(const char *encoding, PyObject *stream, const char *errors) { - PyObject *codecs; + PyObject *codecs, *ret; codecs = _PyCodec_Lookup(encoding); if (codecs == NULL) goto onError; - return build_stream_codec(PyTuple_GET_ITEM(codecs,2),stream,errors); + ret = build_stream_codec(PyTuple_GET_ITEM(codecs,2),stream,errors); + Py_DECREF(codecs); + return ret; onError: return NULL; @@ -313,12 +317,14 @@ PyObject *PyCodec_StreamWriter(const char *encoding, PyObject *stream, const char *errors) { - PyObject *codecs; + PyObject *codecs, *ret; codecs = _PyCodec_Lookup(encoding); if (codecs == NULL) goto onError; - return build_stream_codec(PyTuple_GET_ITEM(codecs,3),stream,errors); + ret = build_stream_codec(PyTuple_GET_ITEM(codecs,3),stream,errors); + Py_DECREF(codecs); + return ret; onError: return NULL; -- cgit v0.12