summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2000-08-27 19:15:31 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2000-08-27 19:15:31 (GMT)
commit2f15b25da2060ab723e0bb82a8f4f713d547b2b8 (patch)
tree09ab0cf972b91f2c24524e927960fd0d23f4bd55 /Python
parent0ae722e0a21e7fff58e94f6b62b6340761312f7e (diff)
downloadcpython-2f15b25da2060ab723e0bb82a8f4f713d547b2b8.zip
cpython-2f15b25da2060ab723e0bb82a8f4f713d547b2b8.tar.gz
cpython-2f15b25da2060ab723e0bb82a8f4f713d547b2b8.tar.bz2
implements PyOS_CheckStack for Windows and MSVC. this fixes a
couple of potential stack overflows, including bug #110615. closes patch #101238
Diffstat (limited to 'Python')
-rw-r--r--Python/pythonrun.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 8d571c3..e951ccd 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1165,3 +1165,32 @@ Py_FdIsInteractive(FILE *fp, char *filename)
(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 */