From: Pauli Date: Sun, 28 Jul 2019 08:21:07 +0000 (+1000) Subject: Fix coverity 1452084 X-Git-Tag: openssl-3.0.0-alpha1~1710 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d753cc333d941d0990ce74821c80b0bfb81e10dc;p=oweals%2Fopenssl.git Fix coverity 1452084 Fix coverity 1452083 Reviewed-by: Bernd Edlinger (Merged from https://github.com/openssl/openssl/pull/9470) --- diff --git a/providers/common/exchange/dh_exch.c b/providers/common/exchange/dh_exch.c index 439b28a27e..b4bfd5f419 100644 --- a/providers/common/exchange/dh_exch.c +++ b/providers/common/exchange/dh_exch.c @@ -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,