From: Guido van Rossum Date: Tue, 21 Jan 1997 21:18:36 +0000 (+0000) Subject: Kill all local variables on function return. This closes a gigantic X-Git-Tag: v1.5a1~453 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a4240132ec0d59b5798453b4b09aff1a2840c240;p=thirdparty%2FPython%2Fcpython.git Kill all local variables on function return. This closes a gigantic leak of memory and file descriptors (thanks for Roj for reporting that!). Alas, the speed goes down by 5%. :-( --- diff --git a/Python/ceval.c b/Python/ceval.c index 651066cedad8..3d2375c7068f 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1696,6 +1696,18 @@ eval_code2(co, globals, locals, why = WHY_EXCEPTION; } } + + /* Kill all local variables */ + + { + int i; + for (i = co->co_nlocals; --i >= 0; ++fastlocals) { + if (*fastlocals != NULL) { + DECREF(*fastlocals); + *fastlocals = NULL; + } + } + } /* Restore previous frame and release the current one */