summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-01-10 17:40:55 (GMT)
committerGuido van Rossum <guido@python.org>1995-01-10 17:40:55 (GMT)
commit58b6873f6b348ca4511ac8fa01bed76b049f6ec5 (patch)
tree363711e5e53a7fe3f419154de9df3c8d77c75ba9 /Python
parent630112ed04e2703a43901b696b3d1b178434e81b (diff)
downloadcpython-58b6873f6b348ca4511ac8fa01bed76b049f6ec5.zip
cpython-58b6873f6b348ca4511ac8fa01bed76b049f6ec5.tar.gz
cpython-58b6873f6b348ca4511ac8fa01bed76b049f6ec5.tar.bz2
fix subtle refcount big in filter() -- Tim MacKenzie
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index f47b408..b3ac3c6 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -186,21 +186,22 @@ builtin_filter(self, args)
if (func == None) {
good = item;
+ INCREF(good);
}
else {
object *arg = mkvalue("(O)", item);
- DECREF(item);
if (arg == NULL)
goto Fail_1;
good = call_object(func, arg);
DECREF(arg);
- if (good == NULL)
+ if (good == NULL) {
+ DECREF(item);
goto Fail_1;
+ }
}
ok = testbool(good);
DECREF(good);
if (ok) {
- INCREF(item);
if (j < len) {
if (setlistitem(result, j++, item) < 0)
goto Fail_1;
@@ -210,6 +211,8 @@ builtin_filter(self, args)
if (addlistitem(result, item) < 0)
goto Fail_1;
}
+ } else {
+ DECREF(item);
}
}