From: Antoine Pitrou Date: Sun, 1 Aug 2010 16:53:42 +0000 (+0000) Subject: Issue #9448: Fix a leak of OS resources (mutexes or semaphores) when X-Git-Tag: v3.2a2~561 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c881f1592f9a2890e1c26ae899351e1cf8b5d622;p=python Issue #9448: Fix a leak of OS resources (mutexes or semaphores) when re-initializing a buffered IO object by calling its `__init__` method. --- diff --git a/Misc/NEWS b/Misc/NEWS index 94bf2b9de0..7d1317d042 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -29,6 +29,9 @@ Extensions Library ------- +- Issue #9448: Fix a leak of OS resources (mutexes or semaphores) when + re-initializing a buffered IO object by calling its ``__init__`` method. + - Issue #1713: Fix os.path.ismount(), which returned true for symbolic links across devices. diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 07fe0a1d81..1dd1ec4ba9 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -636,6 +636,8 @@ _buffered_init(buffered *self) return -1; } #ifdef WITH_THREAD + if (self->lock) + PyThread_free_lock(self->lock); self->lock = PyThread_allocate_lock(); if (self->lock == NULL) { PyErr_SetString(PyExc_RuntimeError, "can't allocate read lock");