From ab88774eb8fe89e5ef485dae9917b1c34c6943a5 Mon Sep 17 00:00:00 2001 From: olszomal Date: Mon, 21 Oct 2024 14:23:45 +0200 Subject: [PATCH] Improved dup-key test --- tests/dup-key.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/dup-key.c b/tests/dup-key.c index 8d168afc..523cc3ff 100644 --- a/tests/dup-key.c +++ b/tests/dup-key.c @@ -120,6 +120,11 @@ int main(int argc, char *argv[]) goto end; } + /* + * ENGINE_init() returned a functional reference, so free the structural + * reference from ENGINE_by_id(). + */ + ENGINE_free(engine); pkey = ENGINE_load_private_key(engine, privkey, 0, 0); if (pkey == NULL) { @@ -158,6 +163,8 @@ int main(int argc, char *argv[]) /* Do it one more time */ pkey = ENGINE_load_private_key(engine, privkey, 0, 0); + /* Free the functional reference from ENGINE_init */ + ENGINE_finish(engine); if (pkey == NULL) { printf("Could not load key\n"); display_openssl_errors(__LINE__); @@ -165,8 +172,6 @@ int main(int argc, char *argv[]) goto end; } - ENGINE_finish(engine); - ret = 0; CONF_modules_unload(1);