From 4023d9b9257aecc3b9cf2ba6c38e3eac8de59313 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Mon, 25 Oct 2021 14:39:34 -0400 Subject: [PATCH] crypto: add missing null check Add null check before using result of ERR_reason_error_string. Coverity reported as an issue and we seem to do a null check in other places we call the function. Signed-off-by: Michael Dawson --- src/crypto/crypto_context.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/crypto/crypto_context.cc b/src/crypto/crypto_context.cc index 4ecd8a8c4204fc..739b559c3b7b22 100644 --- a/src/crypto/crypto_context.cc +++ b/src/crypto/crypto_context.cc @@ -1037,6 +1037,8 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo& args) { // TODO(@jasnell): Should this use ThrowCryptoError? unsigned long err = ERR_get_error(); // NOLINT(runtime/int) const char* str = ERR_reason_error_string(err); + str = str != nullptr ? str : "Unknown error"; + return env->ThrowError(str); } }