coverity 1462554 Dereference after null check
authorPauli <paul.dale@oracle.com>
Sun, 26 Apr 2020 22:42:20 +0000 (08:42 +1000)
committerPauli <paul.dale@oracle.com>
Thu, 30 Apr 2020 10:21:32 +0000 (20:21 +1000)
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/11651)

crypto/evp/p_lib.c

index 053c9cb..bbeb727 100644 (file)
@@ -1212,10 +1212,12 @@ static int pkey_set_type(EVP_PKEY *pkey, ENGINE *e, int type, const char *str,
          * to the |save_type| field, because |type| is supposed to be set
          * to EVP_PKEY_NONE in that case.
          */
-        if (keymgmt != NULL)
-            pkey->save_type = ameth->pkey_id;
-        else if (pkey->ameth != NULL)
-            pkey->type = ameth->pkey_id;
+        if (ameth != NULL) {
+            if (keymgmt != NULL)
+                pkey->save_type = ameth->pkey_id;
+            else if (pkey->ameth != NULL)
+                pkey->type = ameth->pkey_id;
+        }
 #endif
     }
     return 1;