diff --git a/daemon/dtls.c b/daemon/dtls.c index b080a9cc9..e0a8d2690 100644 --- a/daemon/dtls.c +++ b/daemon/dtls.c @@ -161,6 +161,10 @@ static void dump_cert(struct dtls_cert *cert) { /* cert */ fp = open_memstream(&buf, &len); + if (!fp) { + ilogs(crypto, LOG_ERROR, "Failed to allocate memory to dump DTLS certificate"); + return; + } PEM_write_X509(fp, cert->x509); fclose(fp); @@ -169,6 +173,10 @@ static void dump_cert(struct dtls_cert *cert) { /* key */ fp = open_memstream(&buf, &len); + if (!fp) { + ilogs(crypto, LOG_ERROR, "Failed to allocate memory to dump DTLS private key"); + return; + } PEM_write_PrivateKey(fp, cert->pkey, NULL, NULL, 0, 0, NULL); fclose(fp);