From 49b9fdf44125ce26455cd0fa146b8b31f582049f Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Wed, 24 Sep 2014 21:35:39 -0500 Subject: try/finally the bn_ctx manager --- cryptography/hazmat/backends/openssl/backend.py | 8 +++++--- 1 file 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): """ -- cgit v1.2.3