Author: Armin Rigo <[email protected]>
Branch:
Changeset: r85985:dafc333097c5
Date: 2016-08-02 15:09 +0200
http://bitbucket.org/pypy/pypy/changeset/dafc333097c5/
Log: Manual copy from the null_byte_after_str branch: fix a memory leak
in cpyext
diff --git a/pypy/module/cpyext/bytesobject.py
b/pypy/module/cpyext/bytesobject.py
--- a/pypy/module/cpyext/bytesobject.py
+++ b/pypy/module/cpyext/bytesobject.py
@@ -96,7 +96,8 @@
raise oefmt(space.w_ValueError,
"bytes_attach called on object with ob_size %d but trying to store
%d",
py_str.c_ob_size, len(s))
- rffi.c_memcpy(py_str.c_ob_sval, rffi.str2charp(s), len(s))
+ with rffi.scoped_nonmovingbuffer(s) as s_ptr:
+ rffi.c_memcpy(py_str.c_ob_sval, s_ptr, len(s))
py_str.c_ob_sval[len(s)] = '\0'
py_str.c_ob_shash = space.hash_w(w_obj)
py_str.c_ob_sstate = rffi.cast(rffi.INT, 1) # SSTATE_INTERNED_MORTAL
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit