]> granicus.if.org Git - python/commitdiff
Issue #9448: Fix a leak of OS resources (mutexes or semaphores) when
authorAntoine Pitrou <solipsis@pitrou.net>
Sun, 1 Aug 2010 16:53:42 +0000 (16:53 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Sun, 1 Aug 2010 16:53:42 +0000 (16:53 +0000)
re-initializing a buffered IO object by calling its `__init__` method.

Misc/NEWS
Modules/_io/bufferedio.c

index 94bf2b9de072223aa92126c1e684776bad5c9587..7d1317d04294f2a5b62004f984f8d7298ed4f506 100644 (file)
--- 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.
 
index 07fe0a1d81d63c6cb5ba77fdda31db03a6e9b89a..1dd1ec4ba94c9dc3aff409de0df209ea4e5fbad0 100644 (file)
@@ -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");