Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 21496:65f4094f43f4 2.1
Backport rev 2.301 to the 2.1 maintenance branch.
Add checks for stack underflow and overflow.
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Thu, 20 Dec 2001 02:07:36 +0000 |
| parents | c7e833b3cd9c |
| children | 880d3106499b |
line wrap: on
line diff
--- a/Python/ceval.c Wed Dec 19 20:40:54 2001 +0000 +++ b/Python/ceval.c Thu Dec 20 02:07:36 2001 +0000 @@ -402,7 +402,9 @@ #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 @@ 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
