Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 52819:73a7e6aba7b2
Merged revisions 71152 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r71152 | matthias.klose | 2009-04-04 16:18:13 +0200 (Sa, 04 Apr 2009) | 3 lines
- Issue #3845: In PyRun_SimpleFileExFlags avoid invalid memory access with
short file names.
........
| author | Matthias Klose <doko@ubuntu.com> |
|---|---|
| date | Sat, 04 Apr 2009 14:32:42 +0000 |
| parents | 0530aadff696 |
| children | ac209f132b17 |
comparison
equal
deleted
inserted
replaced
| 52816:61b511d05ee9 | 52819:73a7e6aba7b2 |
|---|---|
| 1143 PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, | 1143 PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, |
| 1144 PyCompilerFlags *flags) | 1144 PyCompilerFlags *flags) |
| 1145 { | 1145 { |
| 1146 PyObject *m, *d, *v; | 1146 PyObject *m, *d, *v; |
| 1147 const char *ext; | 1147 const char *ext; |
| 1148 int set_file_name = 0, ret; | 1148 int set_file_name = 0, ret, len; |
| 1149 | 1149 |
| 1150 m = PyImport_AddModule("__main__"); | 1150 m = PyImport_AddModule("__main__"); |
| 1151 if (m == NULL) | 1151 if (m == NULL) |
| 1152 return -1; | 1152 return -1; |
| 1153 d = PyModule_GetDict(m); | 1153 d = PyModule_GetDict(m); |
| 1161 return -1; | 1161 return -1; |
| 1162 } | 1162 } |
| 1163 set_file_name = 1; | 1163 set_file_name = 1; |
| 1164 Py_DECREF(f); | 1164 Py_DECREF(f); |
| 1165 } | 1165 } |
| 1166 ext = filename + strlen(filename) - 4; | 1166 len = strlen(filename); |
| 1167 ext = filename + len - (len > 4 ? 4 : 0); | |
| 1167 if (maybe_pyc_file(fp, filename, ext, closeit)) { | 1168 if (maybe_pyc_file(fp, filename, ext, closeit)) { |
| 1168 /* Try to run a pyc file. First, re-open in binary */ | 1169 /* Try to run a pyc file. First, re-open in binary */ |
| 1169 if (closeit) | 1170 if (closeit) |
| 1170 fclose(fp); | 1171 fclose(fp); |
| 1171 if ((fp = fopen(filename, "rb")) == NULL) { | 1172 if ((fp = fopen(filename, "rb")) == NULL) { |
