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 <mdawson@devrus.com>

PR-URL: https://github.com/nodejs/node/pull/40598
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
This commit is contained in:
Michael Dawson authored and Danielle Adams committed 2022-01-31 23:00:32 -05:00
1 parent cf6379a543
commit 3055edec2f
1 file changed
+2
+2
View File
@@ -1037,6 +1037,8 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo<Value>& 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);
}
}