Skip to content

Commit c757fa5

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 <[email protected]> PR-URL: #40598 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
1 parent 93ea166 commit c757fa5

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)