diff options
Diffstat (limited to 'crypto/dh/dh_key.c')
-rw-r--r-- | crypto/dh/dh_key.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c index 4e9705beef..0854395fc5 100644 --- a/crypto/dh/dh_key.c +++ b/crypto/dh/dh_key.c @@ -418,14 +418,15 @@ size_t ossl_dh_key2buf(const DH *dh, unsigned char **pbuf_out, size_t size, if (!alloc) { if (size >= (size_t)p_size) pbuf = *pbuf_out; + if (pbuf == NULL) + ERR_raise(ERR_LIB_DH, DH_R_INVALID_SIZE); } else { pbuf = OPENSSL_malloc(p_size); } - if (pbuf == NULL) { - ERR_raise(ERR_LIB_DH, ERR_R_MALLOC_FAILURE); + /* Errors raised above */ + if (pbuf == NULL) return 0; - } /* * As per Section 4.2.8.1 of RFC 8446 left pad public * key with zeros to the size of p |