[pypy-commit] pypy py3.5-ssl: avoid calling ffi.gc(p, ...) where p == ffi.NULL
plan_rich
pypy.commits at gmail.com
Mon Nov 28 10:23:24 EST 2016
Author: Richard Plangger <planrichi at gmail.com>
Branch: py3.5-ssl
Changeset: r88701:aaca42d1e26e
Date: 2016-11-28 15:43 +0100
http://bitbucket.org/pypy/pypy/changeset/aaca42d1e26e/
Log: avoid calling ffi.gc(p, ...) where p == ffi.NULL
diff --git a/lib_pypy/_cffi_ssl/_stdssl/__init__.py b/lib_pypy/_cffi_ssl/_stdssl/__init__.py
--- a/lib_pypy/_cffi_ssl/_stdssl/__init__.py
+++ b/lib_pypy/_cffi_ssl/_stdssl/__init__.py
@@ -345,7 +345,11 @@
if ret < 1:
raise pyssl_error(self, ret)
- self.peer_cert = lib.gc(lib.SSL_get_peer_certificate(ssl), lib.X509_free)
+ peer_cert = lib.SSL_get_peer_certificate(ssl)
+ if peer_cert != ffi.NULL:
+ peer_cert = lib.gc(peer_cert, lib.X509_free)
+ self.peer_cert = peer_cert
+
#PySSL_END_ALLOW_THREADS
self.handshake_done = 1
return None
@@ -730,9 +734,10 @@
else:
raise ValueError("invalid protocol version")
+ ctx = lib.SSL_CTX_new(method)
+ if ctx == ffi.NULL:
+ raise ssl_error("failed to allocate SSL context")
self.ctx = ffi.gc(lib.SSL_CTX_new(method), lib.SSL_CTX_free)
- if self.ctx == ffi.NULL:
- raise ssl_error("failed to allocate SSL context")
self._check_hostname = False
More information about the pypy-commit
mailing list