]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Kill all local variables on function return. This closes a gigantic
authorGuido van Rossum <guido@python.org>
Tue, 21 Jan 1997 21:18:36 +0000 (21:18 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 21 Jan 1997 21:18:36 +0000 (21:18 +0000)
leak of memory and file descriptors (thanks for Roj for reporting
that!).  Alas, the speed goes down by 5%. :-(

Python/ceval.c

index 651066cedad8ab7e94f9ac2fede4520ed1ddd22a..3d2375c7068f7321d82a0bbafcb521f9c9ac9d11 100644 (file)
@@ -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 */