From: Jeremy Hylton Date: Thu, 20 Dec 2001 02:07:36 +0000 (+0000) Subject: Backport rev 2.301 to the 2.1 maintenance branch. X-Git-Tag: v2.1.2c1~39 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f7adf24280c05069432d0f2272a786e293c0e99c;p=thirdparty%2FPython%2Fcpython.git Backport rev 2.301 to the 2.1 maintenance branch. Add checks for stack underflow and overflow. --- diff --git a/Python/ceval.c b/Python/ceval.c index 72e4b6b7d697..0872c3e711a8 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -402,7 +402,9 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals, #define BASIC_POP() (*--stack_pointer) #ifdef LLTRACE -#define PUSH(v) (BASIC_PUSH(v), lltrace && prtrace(TOP(), "push")) +#define PUSH(v) { (void)(BASIC_PUSH(v), \ + lltrace && prtrace(TOP(), "push")); \ + assert(STACK_LEVEL() <= f->f_stacksize); } #define POP() (lltrace && prtrace(TOP(), "pop"), BASIC_POP()) #else #define PUSH(v) BASIC_PUSH(v) @@ -681,6 +683,8 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals, w = NULL; for (;;) { + assert(stack_pointer >= f->f_valuestack); /* else underflow */ + assert(STACK_LEVEL() <= f->f_stacksize); /* else overflow */ /* Do periodic things. Doing this every time through the loop would add too much overhead, so we do it only every Nth instruction. We also do it if