mirror of
https://github.com/python/cpython.git
synced 2025-09-08 18:01:44 +00:00
Marc-Andre Lemburg:
Andy Robinson noted a core dump in the codecs.c file. This was introduced by my latest patch which fixed a memory leak in codecs.c. The bug causes all successful codec lookups to fail.
This commit is contained in:
parent
d8fbcc95d9
commit
5ba3c843db
1 changed files with 6 additions and 8 deletions
|
@ -93,7 +93,7 @@ PyObject *lowercasestring(const char *string)
|
||||||
|
|
||||||
PyObject *_PyCodec_Lookup(const char *encoding)
|
PyObject *_PyCodec_Lookup(const char *encoding)
|
||||||
{
|
{
|
||||||
PyObject *result, *args = NULL, *v = NULL;
|
PyObject *result, *args = NULL, *v;
|
||||||
int i, len;
|
int i, len;
|
||||||
|
|
||||||
if (_PyCodec_SearchCache == NULL || _PyCodec_SearchPath == NULL) {
|
if (_PyCodec_SearchCache == NULL || _PyCodec_SearchPath == NULL) {
|
||||||
|
@ -119,15 +119,14 @@ PyObject *_PyCodec_Lookup(const char *encoding)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Next, scan the search functions in order of registration */
|
/* Next, scan the search functions in order of registration */
|
||||||
len = PyList_Size(_PyCodec_SearchPath);
|
|
||||||
if (len < 0)
|
|
||||||
goto onError;
|
|
||||||
|
|
||||||
args = PyTuple_New(1);
|
args = PyTuple_New(1);
|
||||||
if (args == NULL)
|
if (args == NULL)
|
||||||
goto onError;
|
goto onError;
|
||||||
PyTuple_SET_ITEM(args,0,v);
|
PyTuple_SET_ITEM(args,0,v);
|
||||||
v = NULL;
|
|
||||||
|
len = PyList_Size(_PyCodec_SearchPath);
|
||||||
|
if (len < 0)
|
||||||
|
goto onError;
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
PyObject *func;
|
PyObject *func;
|
||||||
|
@ -135,7 +134,7 @@ PyObject *_PyCodec_Lookup(const char *encoding)
|
||||||
func = PyList_GetItem(_PyCodec_SearchPath, i);
|
func = PyList_GetItem(_PyCodec_SearchPath, i);
|
||||||
if (func == NULL)
|
if (func == NULL)
|
||||||
goto onError;
|
goto onError;
|
||||||
result = PyEval_CallObject(func,args);
|
result = PyEval_CallObject(func, args);
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
goto onError;
|
goto onError;
|
||||||
if (result == Py_None) {
|
if (result == Py_None) {
|
||||||
|
@ -163,7 +162,6 @@ PyObject *_PyCodec_Lookup(const char *encoding)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
onError:
|
onError:
|
||||||
Py_XDECREF(v);
|
|
||||||
Py_XDECREF(args);
|
Py_XDECREF(args);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue