Skip to content

Commit 7fa91c8

Browse files
committed
amend: close and decrement count for initial reference only once (avoids unexpected states on repeated Reader.close)
1 parent 245784c commit 7fa91c8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

systemd/_reader.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,10 @@ static PyObject* Reader_close(Reader *self, PyObject *args) {
468468
assert(self);
469469
assert(!args);
470470

471-
self->closed = 1;
472-
decr_ref_count(self); /* decrement initial reference (without incr) */
471+
if (!self->closed) {
472+
self->closed = 1;
473+
decr_ref_count(self); /* decrement initial reference (without incr) */
474+
}
473475
Py_RETURN_NONE;
474476
}
475477

0 commit comments

Comments
 (0)