Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 14227:9f9f3280dc68 legacy-trunk
implements PyOS_CheckStack for Windows and MSVC. this fixes a
couple of potential stack overflows, including bug #110615.
closes patch #101238
| author | Fredrik Lundh <fredrik@pythonware.com> |
|---|---|
| date | Sun, 27 Aug 2000 19:15:31 +0000 |
| parents | 999671f69df4 |
| children | 20377f15b96a |
line wrap: on
line diff
--- a/Python/pythonrun.c Sun Aug 27 19:01:33 2000 +0000 +++ b/Python/pythonrun.c Sun Aug 27 19:15:31 2000 +0000 @@ -1165,3 +1165,32 @@ (strcmp(filename, "<stdin>") == 0) || (strcmp(filename, "???") == 0); } + + +#if defined(USE_STACKCHECK) +#if defined(WIN32) && defined(_MSC_VER) + +/* Stack checking for Microsoft C */ + +#include <malloc.h> +#include <excpt.h> + +int +PyOS_CheckStack() +{ + __try { + /* _alloca throws a stack overflow exception if there's + not enough space left on the stack */ + _alloca(PYOS_STACK_MARGIN * sizeof(void*)); + return 0; + } __except (EXCEPTION_EXECUTE_HANDLER) { + /* just ignore all errors */ + } + return 1; +} + +#endif /* WIN32 && _MSC_VER */ + +/* Alternate implementations can be added here... */ + +#endif /* USE_STACKCHECK */
