aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-09-24 21:35:39 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-09-24 21:35:39 -0500
commit49b9fdf44125ce26455cd0fa146b8b31f582049f (patch)
treef2bc9fae3744f11d8a6a8748e010dddd0b61c884
parent1a7bdab8b006fcd610ddda8f9c2500df1bdd1000 (diff)
downloadcryptography-49b9fdf44125ce26455cd0fa146b8b31f582049f.tar.gz
cryptography-49b9fdf44125ce26455cd0fa146b8b31f582049f.tar.bz2
cryptography-49b9fdf44125ce26455cd0fa146b8b31f582049f.zip
try/finally the bn_ctx manager
-rw-r--r--cryptography/hazmat/backends/openssl/backend.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py
index 5d2fddc1..cb988ac9 100644
--- a/cryptography/hazmat/backends/openssl/backend.py
+++ b/cryptography/hazmat/backends/openssl/backend.py
@@ -1018,9 +1018,11 @@ class Backend(object):
bn_ctx = self._lib.BN_CTX_new()
assert bn_ctx != self._ffi.NULL
bn_ctx = self._ffi.gc(bn_ctx, self._lib.BN_CTX_free)
- self._lib.BN_CTX_start(bn_ctx)
- yield bn_ctx
- self._lib.BN_CTX_end(bn_ctx)
+ try:
+ self._lib.BN_CTX_start(bn_ctx)
+ yield bn_ctx
+ finally:
+ self._lib.BN_CTX_end(bn_ctx)
def _ec_key_set_public_key_affine_coordinates(self, ctx, x, y):
"""