]> granicus.if.org Git - openssl/commitdiff
Fix coverity 1452084
authorPauli <paul.dale@oracle.com>
Sun, 28 Jul 2019 08:21:07 +0000 (18:21 +1000)
committerPauli <paul.dale@oracle.com>
Tue, 30 Jul 2019 08:57:35 +0000 (18:57 +1000)
Fix coverity 1452083

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/9470)

providers/common/exchange/dh_exch.c

index 439b28a27e385bb8b0c21a1ac03cccacdf68f697..b4bfd5f419b226b7d9720df05f94c8c9efda34c4 100644 (file)
@@ -42,22 +42,22 @@ static int dh_init(void *vpdhctx, void *vdh)
 {
     PROV_DH_CTX *pdhctx = (PROV_DH_CTX *)vpdhctx;
 
+    if (pdhctx == NULL || vdh == NULL || !DH_up_ref(vdh))
+        return 0;
     DH_free(pdhctx->dh);
     pdhctx->dh = vdh;
-    DH_up_ref(pdhctx->dh);
-
-    return pdhctx->dh != NULL;
+    return 1;
 }
 
 static int dh_set_peer(void *vpdhctx, void *vdh)
 {
     PROV_DH_CTX *pdhctx = (PROV_DH_CTX *)vpdhctx;
 
+    if (pdhctx == NULL || vdh == NULL || !DH_up_ref(vdh))
+        return 0;
     DH_free(pdhctx->dhpeer);
     pdhctx->dhpeer = vdh;
-    DH_up_ref(pdhctx->dhpeer);
-
-    return pdhctx->dhpeer != NULL;
+    return 1;
 }
 
 static int dh_derive(void *vpdhctx, unsigned char *key, size_t *keylen,