test_provider_ex(): Add missing call failure checks
authorTomas Mraz <tomas@openssl.org>
Thu, 31 Aug 2023 08:26:22 +0000 (10:26 +0200)
committerPauli <pauli@openssl.org>
Sun, 8 Oct 2023 23:21:19 +0000 (10:21 +1100)
Fixes Coverity 1542440

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21913)

test/provider_test.c

index 3268a287a2f6d6dfcb09af52d913d29a05de7a28..2d20d12071ae74652243dd8e02293ada3bce5bbe 100644 (file)
@@ -166,13 +166,15 @@ static int test_provider_ex(OSSL_LIB_CTX **libctx, const char *name)
     int ok = 0;
     long err;
     const char custom_buf[] = "Custom greeting";
-    OSSL_PARAM_BLD *bld = OSSL_PARAM_BLD_new();
+    OSSL_PARAM_BLD *bld = NULL;
     OSSL_PARAM *params = NULL;
 
-    OSSL_PARAM_BLD_push_utf8_string(bld, "greeting", custom_buf, strlen(custom_buf));
-    params = OSSL_PARAM_BLD_to_param(bld);
-
-    OSSL_PARAM_BLD_free(bld);
+    if (!TEST_ptr(bld = OSSL_PARAM_BLD_new())
+        || !TEST_true(OSSL_PARAM_BLD_push_utf8_string(bld, "greeting", custom_buf,
+                                                      strlen(custom_buf)))
+        || !TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld))) {
+        goto err;
+    }
 
     if (!TEST_ptr(prov = OSSL_PROVIDER_load_ex(*libctx, name, params)))
         goto err;
@@ -204,6 +206,7 @@ static int test_provider_ex(OSSL_LIB_CTX **libctx, const char *name)
     ERR_print_errors_fp(stderr);
     ok = 1;
  err:
+    OSSL_PARAM_BLD_free(bld);
     OSSL_PARAM_free(params);
     OSSL_PROVIDER_unload(prov);
     OSSL_LIB_CTX_free(*libctx);