Author: Dan Sanders <[email protected]>
Branch:
Changeset: r73430:7f1e404f5238
Date: 2014-09-10 19:04 +0000
http://bitbucket.org/pypy/pypy/changeset/7f1e404f5238/
Log: 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