Skip to content

Commit 99c1a69

Browse files
mhdawsondanielleadams
authored andcommitted
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: #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>
1 parent e4b1754 commit 99c1a69

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/crypto/crypto_context.cc

+2
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,8 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo<Value>& args) {
10371037
// TODO(@jasnell): Should this use ThrowCryptoError?
10381038
unsigned long err = ERR_get_error(); // NOLINT(runtime/int)
10391039
const char* str = ERR_reason_error_string(err);
1040+
str = str != nullptr ? str : "Unknown error";
1041+
10401042
return env->ThrowError(str);
10411043
}
10421044
}

0 commit comments

Comments
 (0)