Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 39135:12e973bdfeee legacy-trunk
Fix more memory allocation issues found with failmalloc.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Sat, 22 Jul 2006 16:20:49 +0000 |
| parents | 7c09b66f04bd |
| children | 9a1288d8200f |
comparison
equal
deleted
inserted
replaced
| 39134:079e42e0b826 | 39135:12e973bdfeee |
|---|---|
| 744 PyErr_Clear(); | 744 PyErr_Clear(); |
| 745 else if (PyString_Check(w)) | 745 else if (PyString_Check(w)) |
| 746 ps2 = PyString_AsString(w); | 746 ps2 = PyString_AsString(w); |
| 747 } | 747 } |
| 748 arena = PyArena_New(); | 748 arena = PyArena_New(); |
| 749 if (arena == NULL) { | |
| 750 Py_XDECREF(v); | |
| 751 Py_XDECREF(w); | |
| 752 return -1; | |
| 753 } | |
| 749 mod = PyParser_ASTFromFile(fp, filename, | 754 mod = PyParser_ASTFromFile(fp, filename, |
| 750 Py_single_input, ps1, ps2, | 755 Py_single_input, ps1, ps2, |
| 751 flags, &errcode, arena); | 756 flags, &errcode, arena); |
| 752 Py_XDECREF(v); | 757 Py_XDECREF(v); |
| 753 Py_XDECREF(w); | 758 Py_XDECREF(w); |
| 1201 PyObject * | 1206 PyObject * |
| 1202 PyRun_StringFlags(const char *str, int start, PyObject *globals, | 1207 PyRun_StringFlags(const char *str, int start, PyObject *globals, |
| 1203 PyObject *locals, PyCompilerFlags *flags) | 1208 PyObject *locals, PyCompilerFlags *flags) |
| 1204 { | 1209 { |
| 1205 PyObject *ret = NULL; | 1210 PyObject *ret = NULL; |
| 1211 mod_ty mod; | |
| 1206 PyArena *arena = PyArena_New(); | 1212 PyArena *arena = PyArena_New(); |
| 1207 mod_ty mod; | |
| 1208 | |
| 1209 if (arena == NULL) | 1213 if (arena == NULL) |
| 1210 return NULL; | 1214 return NULL; |
| 1211 | 1215 |
| 1212 mod = PyParser_ASTFromString(str, "<string>", start, flags, arena); | 1216 mod = PyParser_ASTFromString(str, "<string>", start, flags, arena); |
| 1213 if (mod != NULL) | 1217 if (mod != NULL) |
| 1219 PyObject * | 1223 PyObject * |
| 1220 PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, | 1224 PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, |
| 1221 PyObject *locals, int closeit, PyCompilerFlags *flags) | 1225 PyObject *locals, int closeit, PyCompilerFlags *flags) |
| 1222 { | 1226 { |
| 1223 PyObject *ret; | 1227 PyObject *ret; |
| 1228 mod_ty mod; | |
| 1224 PyArena *arena = PyArena_New(); | 1229 PyArena *arena = PyArena_New(); |
| 1225 mod_ty mod; | |
| 1226 | |
| 1227 if (arena == NULL) | 1230 if (arena == NULL) |
| 1228 return NULL; | 1231 return NULL; |
| 1229 | 1232 |
| 1230 mod = PyParser_ASTFromFile(fp, filename, start, 0, 0, | 1233 mod = PyParser_ASTFromFile(fp, filename, start, 0, 0, |
| 1231 flags, NULL, arena); | 1234 flags, NULL, arena); |
| 1289 PyObject * | 1292 PyObject * |
| 1290 Py_CompileStringFlags(const char *str, const char *filename, int start, | 1293 Py_CompileStringFlags(const char *str, const char *filename, int start, |
| 1291 PyCompilerFlags *flags) | 1294 PyCompilerFlags *flags) |
| 1292 { | 1295 { |
| 1293 PyCodeObject *co; | 1296 PyCodeObject *co; |
| 1297 mod_ty mod; | |
| 1294 PyArena *arena = PyArena_New(); | 1298 PyArena *arena = PyArena_New(); |
| 1295 mod_ty mod = PyParser_ASTFromString(str, filename, start, flags, arena); | 1299 if (arena == NULL) |
| 1300 return NULL; | |
| 1301 | |
| 1302 mod = PyParser_ASTFromString(str, filename, start, flags, arena); | |
| 1296 if (mod == NULL) { | 1303 if (mod == NULL) { |
| 1297 PyArena_Free(arena); | 1304 PyArena_Free(arena); |
| 1298 return NULL; | 1305 return NULL; |
| 1299 } | 1306 } |
| 1300 if (flags && (flags->cf_flags & PyCF_ONLY_AST)) { | 1307 if (flags && (flags->cf_flags & PyCF_ONLY_AST)) { |
| 1309 | 1316 |
| 1310 struct symtable * | 1317 struct symtable * |
| 1311 Py_SymtableString(const char *str, const char *filename, int start) | 1318 Py_SymtableString(const char *str, const char *filename, int start) |
| 1312 { | 1319 { |
| 1313 struct symtable *st; | 1320 struct symtable *st; |
| 1321 mod_ty mod; | |
| 1314 PyArena *arena = PyArena_New(); | 1322 PyArena *arena = PyArena_New(); |
| 1315 mod_ty mod = PyParser_ASTFromString(str, filename, start, NULL, arena); | 1323 if (arena == NULL) |
| 1324 return NULL; | |
| 1325 | |
| 1326 mod = PyParser_ASTFromString(str, filename, start, NULL, arena); | |
| 1316 if (mod == NULL) { | 1327 if (mod == NULL) { |
| 1317 PyArena_Free(arena); | 1328 PyArena_Free(arena); |
| 1318 return NULL; | 1329 return NULL; |
| 1319 } | 1330 } |
| 1320 st = PySymtable_Build(mod, filename, 0); | 1331 st = PySymtable_Build(mod, filename, 0); |
