[Python-checkins] CVS: python/dist/src/Python pythonrun.c,2.108,2.109

Fredrik Lundh python-dev@python.org
Sun, 27 Aug 2000 12:15:33 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory slayer.i.sourceforge.net:/tmp/cvs-serv28530/Python

Modified Files:
	pythonrun.c 
Log Message:


implements PyOS_CheckStack for Windows and MSVC.  this fixes a
couple of potential stack overflows, including bug #110615.

closes patch #101238 


Index: pythonrun.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v
retrieving revision 2.108
retrieving revision 2.109
diff -C2 -r2.108 -r2.109
*** pythonrun.c	2000/08/25 21:00:46	2.108
--- pythonrun.c	2000/08/27 19:15:31	2.109
***************
*** 1166,1167 ****
--- 1166,1196 ----
  	       (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 */