aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-02-13 08:35:44 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-02-19 18:13:29 -0600
commite81438a422cade9a512bf4457629a663ccd18666 (patch)
tree453409e283b16597c80b31a96d281bdc76395f01 /src
parent8c2539c8a67c0530633de2e74df8dd68f1b63193 (diff)
downloadcryptography-e81438a422cade9a512bf4457629a663ccd18666.tar.gz
cryptography-e81438a422cade9a512bf4457629a663ccd18666.tar.bz2
cryptography-e81438a422cade9a512bf4457629a663ccd18666.zip
move gc above potential exception
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/hazmat/backends/openssl/backend.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py
index 3e95c88b..87ee1d7a 100644
--- a/src/cryptography/hazmat/backends/openssl/backend.py
+++ b/src/cryptography/hazmat/backends/openssl/backend.py
@@ -725,12 +725,12 @@ class Backend(object):
mem_bio = self._bytes_to_bio(data)
key = self._lib.d2i_PrivateKey_bio(mem_bio.bio, self._ffi.NULL)
if key != self._ffi.NULL:
+ key = self._ffi.gc(key, self._lib.EVP_PKEY_free)
if password is not None:
raise TypeError(
"Password was given but private key is not encrypted."
)
- key = self._ffi.gc(key, self._lib.EVP_PKEY_free)
return key
else:
self._consume_errors()
@@ -744,11 +744,11 @@ class Backend(object):
if info != self._ffi.NULL:
key = self._lib.EVP_PKCS82PKEY(info)
assert key != self._ffi.NULL
+ key = self._ffi.gc(key, self._lib.EVP_PKEY_free)
if password is not None:
raise TypeError(
"Password was given but private key is not encrypted."
)
- key = self._ffi.gc(key, self._lib.EVP_PKEY_free)
return key
else:
self._consume_errors()