From 6da0c1cd9f85cfd01983cf1bf779320474bef57d Mon Sep 17 00:00:00 2001
From: Dmitry Belyavskiy <beldmit@gmail.com>
Date: Sun, 27 Sep 2020 11:11:51 +0300
Subject: [PATCH] Fix Coverity #305799

---
 gost_ameth.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gost_ameth.c b/gost_ameth.c
index 4a95de4..2582d63 100644
--- a/gost_ameth.c
+++ b/gost_ameth.c
@@ -977,7 +977,10 @@ static int pub_encode_gost_ec(X509_PUBKEY *pub, const EVP_PKEY *pk)
         GOSTerr(GOST_F_PUB_ENCODE_GOST_EC, ERR_R_MALLOC_FAILURE);
         goto err;
     }
-    EC_GROUP_get_order(EC_KEY_get0_group(ec), order, NULL);
+    if (EC_GROUP_get_order(EC_KEY_get0_group(ec), order, NULL) == 0) {
+        GOSTerr(GOST_F_PUB_ENCODE_GOST_EC, ERR_R_INTERNAL_ERROR);
+        goto err;
+    }
     pub_key = EC_KEY_get0_public_key(ec);
     if (!pub_key) {
         GOSTerr(GOST_F_PUB_ENCODE_GOST_EC, GOST_R_PUBLIC_KEY_UNDEFINED);
-- 
2.39.5