[pypy-commit] pypy default: issue 2183 -- free a buffer that OpenSSL allocates when we're done with it

alex_gaynor noreply at buildbot.pypy.org
Fri Nov 6 15:44:15 EST 2015


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r80570:3851b04286c3
Date: 2015-11-06 15:44 -0500
http://bitbucket.org/pypy/pypy/changeset/3851b04286c3/

Log:	issue 2183 -- free a buffer that OpenSSL allocates when we're done
	with it

diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py
--- a/pypy/module/_ssl/interp_ssl.py
+++ b/pypy/module/_ssl/interp_ssl.py
@@ -924,8 +924,11 @@
         length = libssl_ASN1_STRING_to_UTF8(buf_ptr, value)
         if length < 0:
             raise _ssl_seterror(space, None, 0)
-        w_value = space.wrap(rffi.charpsize2str(buf_ptr[0], length))
-        w_value = space.call_method(w_value, "decode", space.wrap("utf-8"))
+        try:
+            w_value = space.wrap(rffi.charpsize2str(buf_ptr[0], length))
+            w_value = space.call_method(w_value, "decode", space.wrap("utf-8"))
+        finally:
+            libssl_OPENSSL_free(buf_ptr[0])
 
     return space.newtuple([w_name, w_value])
 


More information about the pypy-commit mailing list