It probably can't, but using `finally` is a reasonable, idiomatic, and safe
practice here. Better to be obviously correct than to make every reader
reverse engineer that it's fine.


On Mon, Feb 10, 2014 at 8:22 AM, Paul Kehrer <notifications@github.com>wrote:

> In cryptography/hazmat/backends/openssl/backend.py:
>
> > @@ -259,6 +261,42 @@ def _handle_error_code(self, code):
> >              )
> >          )
> >
> > +    def _bn_to_int(self, bn):
> > +        hex_str = self._lib.BN_bn2hex(bn)
> > +        assert hex_str != self._ffi.NULL
> > +        hex_str = self._ffi.gc(hex_str, self._lib.OPENSSL_free)
>
> Can int() raise on anything other than an invalid hex string in this
> case? I guess you could get an invalid hex string if bn2hex didn't error
> but returned non-hexadecimal (memory bit flip?).
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/pyca/cryptography/pull/580/files#r9589871>
> .
>



-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: 125F 5C67 DFE9 4084