Kaydet (Commit) 58b6873f authored tarafından Guido van Rossum's avatar Guido van Rossum

fix subtle refcount big in filter() -- Tim MacKenzie

üst 630112ed
...@@ -186,21 +186,22 @@ builtin_filter(self, args) ...@@ -186,21 +186,22 @@ builtin_filter(self, args)
if (func == None) { if (func == None) {
good = item; good = item;
INCREF(good);
} }
else { else {
object *arg = mkvalue("(O)", item); object *arg = mkvalue("(O)", item);
DECREF(item);
if (arg == NULL) if (arg == NULL)
goto Fail_1; goto Fail_1;
good = call_object(func, arg); good = call_object(func, arg);
DECREF(arg); DECREF(arg);
if (good == NULL) if (good == NULL) {
DECREF(item);
goto Fail_1; goto Fail_1;
}
} }
ok = testbool(good); ok = testbool(good);
DECREF(good); DECREF(good);
if (ok) { if (ok) {
INCREF(item);
if (j < len) { if (j < len) {
if (setlistitem(result, j++, item) < 0) if (setlistitem(result, j++, item) < 0)
goto Fail_1; goto Fail_1;
...@@ -210,6 +211,8 @@ builtin_filter(self, args) ...@@ -210,6 +211,8 @@ builtin_filter(self, args)
if (addlistitem(result, item) < 0) if (addlistitem(result, item) < 0)
goto Fail_1; goto Fail_1;
} }
} else {
DECREF(item);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment