ecdsa_ossl: address coverity nit
authorBenjamin Kaduk <kaduk@mit.edu>
Mon, 18 Jun 2018 01:00:02 +0000 (20:00 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 22 Jun 2018 16:54:30 +0000 (11:54 -0500)
BN_CTX_end() does not handle NULL input, so we must manually check
before calling from the cleanup handler.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6502)

crypto/ec/ecdsa_ossl.c

index 277ac16bdfee8f2063767bb077a8505778b7d66b..dfb0d192d931d4ad01c07542aa11408f7d177053 100644 (file)
@@ -336,7 +336,8 @@ ECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len,
         ECDSA_SIG_free(ret);
         ret = NULL;
     }
-    BN_CTX_end(ctx);
+    if (ctx != NULL)
+        BN_CTX_end(ctx);
     BN_CTX_free(ctx);
     BN_clear_free(kinv);
     return ret;