Author: Brian Kearns <[email protected]>
Branch:
Changeset: r73431:6cfe51b6af4c
Date: 2014-09-10 16:32 -0700
http://bitbucket.org/pypy/pypy/changeset/6cfe51b6af4c/
Log: Merged in dansanders/pypy (pull request #278)
Fix memory leak in sandbox I/O.
diff --git a/rpython/translator/sandbox/rsandbox.py
b/rpython/translator/sandbox/rsandbox.py
--- a/rpython/translator/sandbox/rsandbox.py
+++ b/rpython/translator/sandbox/rsandbox.py
@@ -61,13 +61,16 @@
def need_more_data(self):
buflen = self.buflen
buf = lltype.malloc(rffi.CCHARP.TO, buflen, flavor='raw')
- buflen = rffi.cast(rffi.SIZE_T, buflen)
- count = ll_read_not_sandboxed(self.fd, buf, buflen)
- count = rffi.cast(lltype.Signed, count)
- if count <= 0:
- raise IOError
- self.buf += ''.join([buf[i] for i in range(count)])
- self.buflen *= 2
+ try:
+ buflen = rffi.cast(rffi.SIZE_T, buflen)
+ count = ll_read_not_sandboxed(self.fd, buf, buflen)
+ count = rffi.cast(lltype.Signed, count)
+ if count <= 0:
+ raise IOError
+ self.buf += ''.join([buf[i] for i in range(count)])
+ self.buflen *= 2
+ finally:
+ lltype.free(buf, flavor='raw')
def sandboxed_io(buf):
STDIN = 0
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit