diff options
author | Mark Hammond <mhammond@skippinet.com.au> | 2002-07-18 23:06:17 (GMT) |
---|---|---|
committer | Mark Hammond <mhammond@skippinet.com.au> | 2002-07-18 23:06:17 (GMT) |
commit | e21262ca9e286aee27741eb8bb69508a911ec10b (patch) | |
tree | 014a05cf29c426f927f21f36751c0b356e28ddb1 /Python/codecs.c | |
parent | 5a7ef7e2b56639073759d9b8a33a6c59fb8e4498 (diff) | |
download | cpython-e21262ca9e286aee27741eb8bb69508a911ec10b.zip cpython-e21262ca9e286aee27741eb8bb69508a911ec10b.tar.gz cpython-e21262ca9e286aee27741eb8bb69508a911ec10b.tar.bz2 |
Fix bug [ 549731 ] Unicode encoders appears to leak references.
Python 2.2.1 bugfix candidate.
Diffstat (limited to 'Python/codecs.c')
-rw-r--r-- | Python/codecs.c | 14 |
1 files 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; |