[pypy-svn] pypy fast-forward: Fix a leak in _multiprocessing

amauryfa commits-noreply at bitbucket.org
Mon Jan 10 14:40:07 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: fast-forward
Changeset: r40554:ecc889e7a4e7
Date: 2011-01-10 14:25 +0100
http://bitbucket.org/pypy/pypy/changeset/ecc889e7a4e7/

Log:	Fix a leak in _multiprocessing

diff --git a/pypy/module/_multiprocessing/interp_connection.py b/pypy/module/_multiprocessing/interp_connection.py
--- a/pypy/module/_multiprocessing/interp_connection.py
+++ b/pypy/module/_multiprocessing/interp_connection.py
@@ -267,10 +267,9 @@
             lltype.free(message, flavor='raw')
 
     def do_recv_string(self, space, buflength, maxlength):
-        length_ptr = lltype.malloc(rffi.CArrayPtr(rffi.UINT).TO, 1,
-                                   flavor='raw')
-        self._recvall(space, rffi.cast(rffi.CCHARP, length_ptr), 4)
-        length = intmask(length_ptr[0])
+        with lltype.scoped_alloc(rffi.CArrayPtr(rffi.UINT).TO, 1) as length_ptr:
+            self._recvall(space, rffi.cast(rffi.CCHARP, length_ptr), 4)
+            length = intmask(length_ptr[0])
         if length > maxlength: # bad message, close connection
             self.flags &= ~READABLE
             if self.flags == 0:
@@ -455,6 +454,7 @@
             return length, newbuf
         finally:
             lltype.free(read_ptr, flavor='raw')
+            lltype.free(left_ptr, flavor='raw')
 
     def do_poll(self, space, timeout):
         from pypy.module._multiprocessing.interp_win32 import (


More information about the Pypy-commit mailing list