Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5ba3c84

Browse files
committed
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.
1 parent d8fbcc9 commit 5ba3c84

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

Python/codecs.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ PyObject *lowercasestring(const char *string)
9393

9494
PyObject *_PyCodec_Lookup(const char *encoding)
9595
{
96-
PyObject *result, *args = NULL, *v = NULL;
96+
PyObject *result, *args = NULL, *v;
9797
int i, len;
9898

9999
if (_PyCodec_SearchCache == NULL || _PyCodec_SearchPath == NULL) {
@@ -119,23 +119,22 @@ PyObject *_PyCodec_Lookup(const char *encoding)
119119
}
120120

121121
/* Next, scan the search functions in order of registration */
122-
len = PyList_Size(_PyCodec_SearchPath);
123-
if (len < 0)
124-
goto onError;
125-
126122
args = PyTuple_New(1);
127123
if (args == NULL)
128124
goto onError;
129125
PyTuple_SET_ITEM(args,0,v);
130-
v = NULL;
126+
127+
len = PyList_Size(_PyCodec_SearchPath);
128+
if (len < 0)
129+
goto onError;
131130

132131
for (i = 0; i < len; i++) {
133132
PyObject *func;
134133

135134
func = PyList_GetItem(_PyCodec_SearchPath, i);
136135
if (func == NULL)
137136
goto onError;
138-
result = PyEval_CallObject(func,args);
137+
result = PyEval_CallObject(func, args);
139138
if (result == NULL)
140139
goto onError;
141140
if (result == Py_None) {
@@ -163,7 +162,6 @@ PyObject *_PyCodec_Lookup(const char *encoding)
163162
return result;
164163

165164
onError:
166-
Py_XDECREF(v);
167165
Py_XDECREF(args);
168166
return NULL;
169167
}

0 commit comments

Comments
 (0)