diff options
author | Barry Warsaw <barry@python.org> | 2000-03-20 16:36:48 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2000-03-20 16:36:48 (GMT) |
commit | 51ac58039f62ef9d605974dae32a6ada9c26039b (patch) | |
tree | c8aee44da7330978efe15671b2c9e98bc898eea3 /Python/codecs.c | |
parent | abc411bac883c1706a9dcc8b1bea85a0b940cbfb (diff) | |
download | cpython-51ac58039f62ef9d605974dae32a6ada9c26039b.zip cpython-51ac58039f62ef9d605974dae32a6ada9c26039b.tar.gz cpython-51ac58039f62ef9d605974dae32a6ada9c26039b.tar.bz2 |
On 17-Mar-2000, Marc-Andre Lemburg said:
Attached you find an update of the Unicode implementation.
The patch is against the current CVS version. I would appreciate
if someone with CVS checkin permissions could check the changes
in.
The patch contains all bugs and patches sent this week and also
fixes a leak in the codecs code and a bug in the free list code
for Unicode objects (which only shows up when compiling Python
with Py_DEBUG; thanks to MarkH for spotting this one).
Diffstat (limited to 'Python/codecs.c')
-rw-r--r-- | Python/codecs.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Python/codecs.c b/Python/codecs.c index 5075a20..2d49377 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -93,9 +93,14 @@ PyObject *lowercasestring(const char *string) PyObject *_PyCodec_Lookup(const char *encoding) { - PyObject *result, *args = NULL, *v; + PyObject *result, *args = NULL, *v = NULL; int i, len; + if (_PyCodec_SearchCache == NULL || _PyCodec_SearchPath == NULL) { + PyErr_SetString(PyExc_SystemError, + "codec module not properly initialized"); + goto onError; + } if (!import_encodings_called) import_encodings(); @@ -109,6 +114,7 @@ PyObject *_PyCodec_Lookup(const char *encoding) result = PyDict_GetItem(_PyCodec_SearchCache, v); if (result != NULL) { Py_INCREF(result); + Py_DECREF(v); return result; } @@ -121,6 +127,7 @@ PyObject *_PyCodec_Lookup(const char *encoding) if (args == NULL) goto onError; PyTuple_SET_ITEM(args,0,v); + v = NULL; for (i = 0; i < len; i++) { PyObject *func; @@ -146,7 +153,7 @@ PyObject *_PyCodec_Lookup(const char *encoding) if (i == len) { /* XXX Perhaps we should cache misses too ? */ PyErr_SetString(PyExc_LookupError, - "unkown encoding"); + "unknown encoding"); goto onError; } @@ -156,6 +163,7 @@ PyObject *_PyCodec_Lookup(const char *encoding) return result; onError: + Py_XDECREF(v); Py_XDECREF(args); return NULL; } @@ -378,5 +386,7 @@ void _PyCodecRegistry_Init() void _PyCodecRegistry_Fini() { Py_XDECREF(_PyCodec_SearchPath); + _PyCodec_SearchPath = NULL; Py_XDECREF(_PyCodec_SearchCache); + _PyCodec_SearchCache = NULL; } |