Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 21477:ccb26a118867 legacy-trunk
SF bug #494668: PUSH() should assert-fail on overflow.
eval_frame(): Added asserts to the top of the eval loop, to verify
that the eval stack pointer is in bounds, plus some comments.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Wed, 19 Dec 2001 04:11:07 +0000 |
| parents | aac23331a25d |
| children | ca27d82ac89b |
line wrap: on
line diff
--- a/Python/ceval.c Tue Dec 18 23:22:01 2001 +0000 +++ b/Python/ceval.c Wed Dec 19 04:11:07 2001 +0000 @@ -497,7 +497,7 @@ #ifdef DXPAIRS int lastopcode = 0; #endif - PyObject **stack_pointer; + PyObject **stack_pointer; /* Next free slot in value stack */ register unsigned char *next_instr; register int opcode=0; /* Current opcode */ register int oparg=0; /* Current opcode argument, if any */ @@ -586,7 +586,7 @@ next_instr = first_instr + f->f_lasti; stack_pointer = f->f_stacktop; assert(stack_pointer != NULL); - f->f_stacktop = NULL; + f->f_stacktop = NULL; /* remains NULL unless yield suspends frame */ if (tstate->use_tracing) { if (tstate->c_tracefunc != NULL) { @@ -634,6 +634,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
