Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 1079:e4c6a0dd5c2b legacy-trunk
* bltinmodule.c: added built-in function cmp(a, b)
* flmodule.c: added {do,check}_only_forms to fl's list of functions;
and don't print a message when an unknown object is returned.
* pythonrun.c: catch SIGHUP and SIGTERM to do essential cleanup.
* Made jpegmodule.c smaller by using getargs() and mkvalue() consistently.
* Increased parser stack size to 500 in parser.h.
* Implemented custom allocation of stack frames to frameobject.c and
added dynamic stack overflow checks (value stack only) to ceval.c.
(There seems to be a bug left: sometimes stack traces don't make sense.)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Sun, 18 Oct 1992 18:53:57 +0000 |
| parents | 2c0432fcc270 |
| children | ce718457b172 |
line wrap: on
line diff
--- a/Python/ceval.c Sun Oct 18 17:09:59 1992 +0000 +++ b/Python/ceval.c Sun Oct 18 18:53:57 1992 +0000 @@ -204,6 +204,9 @@ #define BASIC_PUSH(v) (*stack_pointer++ = (v)) #define BASIC_POP() (*--stack_pointer) +#define CHECK_STACK(n) (STACK_LEVEL() + (n) < f->f_nvalues || \ + (stack_pointer = extend_stack(f, STACK_LEVEL(), n))) + #ifdef LLTRACE #define PUSH(v) (BASIC_PUSH(v), lltrace && prtrace(TOP(), "push")) #define POP() (lltrace && prtrace(TOP(), "pop"), BASIC_POP()) @@ -324,6 +327,11 @@ } #endif + if (!CHECK_STACK(3)) { + x = NULL; + break; + } + /* Main switch on opcode */ switch (opcode) { @@ -763,6 +771,10 @@ x = gettupleslice(v, oparg, gettuplesize(v)); if (x != NULL) { PUSH(x); + if (!CHECK_STACK(oparg)) { + x = NULL; + break; + } for (; --oparg >= 0; ) { w = gettupleitem(v, oparg); INCREF(w); @@ -858,6 +870,10 @@ why = WHY_EXCEPTION; } else { + if (!CHECK_STACK(oparg)) { + x = NULL; + break; + } for (; --oparg >= 0; ) { w = gettupleitem(v, oparg); INCREF(w); @@ -879,6 +895,10 @@ why = WHY_EXCEPTION; } else { + if (!CHECK_STACK(oparg)) { + x = NULL; + break; + } for (; --oparg >= 0; ) { w = getlistitem(v, oparg); INCREF(w);
