]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test/evp_test.c: avoid resource leak in digest_test_run()
authorEugene Syromiatnikov <esyr@openssl.org>
Mon, 26 Jan 2026 08:54:31 +0000 (09:54 +0100)
committerNeil Horman <nhorman@openssl.org>
Wed, 28 Jan 2026 12:56:46 +0000 (07:56 -0500)
The function can return on ctrl2params() returning 0 without freeing
the allocated memory associated with the got pointer.  Fix it by jumping
to the err label that performs the cleanup instead of returning
immediately.

Resolves: https://scan5.scan.coverity.com/#/project-view/65248/10222?selectedIssue=1680647
Fixes: 9c738431411e "Add support for CSHAKE."
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Wed Jan 28 12:57:04 2026
(Merged from https://github.com/openssl/openssl/pull/29757)

test/evp_test.c

index bd7ae805026a94dfcd24c2ff82dfbcdc84cac31f..64d7b52b5b8889ab751ccc0ecd936035763b99c5 100644 (file)
@@ -835,7 +835,7 @@ static int digest_test_run(EVP_TEST *t)
     if (sk_OPENSSL_STRING_num(expected->controls) > 0) {
         if (!ctrl2params(t, expected->controls, defined_params,
                 params, OSSL_NELEM(params), &params_n))
-            return 0;
+            goto err;
         p = params + params_n;
     }