Skip to content

Commit c425fb1

Browse files
committed
fix error case in d2iTryAltDhKey
1 parent bac0563 commit c425fb1

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

wolfcrypt/src/evp_pk.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,13 +398,14 @@ static int d2iTryAltDhKey(WOLFSSL_EVP_PKEY** out, const unsigned char* mem,
398398
/* Create DH key object from data. */
399399
dhObj = wolfSSL_DH_new();
400400
if (dhObj == NULL) {
401-
return 0;
401+
return WOLFSSL_FATAL_ERROR;
402402
}
403403

404404
key = (DhKey*)dhObj->internal;
405405
/* Try decoding data as a DH public key. */
406406
if (wc_DhKeyDecode(mem, &keyIdx, key, (word32)memSz) != 0) {
407-
ret = 0;
407+
wolfSSL_DH_free(dhObj);
408+
return WOLFSSL_FATAL_ERROR;
408409
}
409410
if (ret == 1) {
410411
/* DH key has data and is external to DH object. */

0 commit comments

Comments
 (0)