test: coverity 1455749 - dereference after null check
authorPauli <ppzgs1@gmail.com>
Wed, 17 Mar 2021 03:05:37 +0000 (13:05 +1000)
committerPauli <ppzgs1@gmail.com>
Sat, 20 Mar 2021 00:18:32 +0000 (10:18 +1000)
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14589)

test/evp_test.c

index 0c81939f2e4424c9c00bd5bb94dd8034676d6f20..2bb837e6e70c496f8308252915f2f0391bb2e3fc 100644 (file)
@@ -1460,15 +1460,16 @@ static void pkey_test_cleanup(EVP_TEST *t)
 static int pkey_test_ctrl(EVP_TEST *t, EVP_PKEY_CTX *pctx,
                           const char *value)
 {
-    int rv;
+    int rv = 0;
     char *p, *tmpval;
 
     if (!TEST_ptr(tmpval = OPENSSL_strdup(value)))
         return 0;
     p = strchr(tmpval, ':');
-    if (p != NULL)
+    if (p != NULL) {
         *p++ = '\0';
-    rv = EVP_PKEY_CTX_ctrl_str(pctx, tmpval, p);
+        rv = EVP_PKEY_CTX_ctrl_str(pctx, tmpval, p);
+    }
     if (rv == -2) {
         t->err = "PKEY_CTRL_INVALID";
         rv = 1;