From e5a75311a669053ae470ee2884cb33fc70ebd1de Mon Sep 17 00:00:00 2001
From: K1 <dongbeiouba@gmail.com>
Date: Mon, 6 Jan 2025 16:20:26 +0800
Subject: [PATCH] Fix compilation failure with ec_elgamal but disable twisted
 elgamal

Fix compilation issue found in Coverage.
---
 crypto/ec/ec_elgamal_crypt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/crypto/ec/ec_elgamal_crypt.c b/crypto/ec/ec_elgamal_crypt.c
index a237ee496..76f247562 100644
--- a/crypto/ec/ec_elgamal_crypt.c
+++ b/crypto/ec/ec_elgamal_crypt.c
@@ -98,13 +98,13 @@ EC_ELGAMAL_CTX *EC_ELGAMAL_CTX_new(EC_KEY *key, const EC_POINT *h, int32_t flag)
     ctx->flag = flag;
 
     return ctx;
-#ifndef OPENSSL_NO_TWISTED_EC_ELGAMAL
 err:
+#ifndef OPENSSL_NO_TWISTED_EC_ELGAMAL
     OPENSSL_free(buf);
     BN_CTX_free(bn_ctx);
+#endif
     EC_ELGAMAL_CTX_free(ctx);
     return NULL;
-#endif
 }
 
 EC_ELGAMAL_CTX *EC_ELGAMAL_CTX_dup(EC_ELGAMAL_CTX *ctx)