From d753cc333d941d0990ce74821c80b0bfb81e10dc Mon Sep 17 00:00:00 2001 From: Pauli Date: Sun, 28 Jul 2019 18:21:07 +1000 Subject: [PATCH] Fix coverity 1452084 Fix coverity 1452083 Reviewed-by: Bernd Edlinger (Merged from https://github.com/openssl/openssl/pull/9470) --- providers/common/exchange/dh_exch.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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, -- 2.25.1