vtls: avoid NULL deref on bad PEM input

Spotted by Coverity

Closes #17274
This commit is contained in:
Daniel Stenberg 2025-05-07 16:09:55 +02:00
parent 7b92844639
commit 3a2689712a
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -698,9 +698,12 @@ static CURLcode pubkey_pem_to_der(const char *pem,
++pem_count;
}
result = curlx_base64_decode(curlx_dyn_ptr(&pbuf), der, der_len);
curlx_dyn_free(&pbuf);
if(curlx_dyn_len(&pbuf)) {
result = curlx_base64_decode(curlx_dyn_ptr(&pbuf), der, der_len);
curlx_dyn_free(&pbuf);
}
else
result = CURLE_BAD_CONTENT_ENCODING;
return result;
}