@@ -67,6 +67,14 @@ namespace crypto {
6767
6868using namespace v8 ;
6969
70+ // Forcibly clear OpenSSL's error stack on return. This stops stale errors
71+ // from popping up later in the lifecycle of crypto operations where they
72+ // would cause spurious failures. It's a rather blunt method, though.
73+ // ERR_clear_error() isn't necessarily cheap either.
74+ struct ClearErrorOnReturn {
75+ ~ClearErrorOnReturn () { ERR_clear_error (); }
76+ };
77+
7078static Persistent<String> errno_symbol;
7179static Persistent<String> syscall_symbol;
7280static Persistent<String> subject_symbol;
@@ -908,13 +916,6 @@ int Connection::HandleBIOError(BIO *bio, const char* func, int rv) {
908916
909917
910918int Connection::HandleSSLError (const char * func, int rv, ZeroStatus zs) {
911- // Forcibly clear OpenSSL's error stack on return. This stops stale errors
912- // from popping up later in the lifecycle of the SSL connection where they
913- // would cause spurious failures. It's a rather blunt method, though.
914- // ERR_clear_error() isn't necessarily cheap either.
915- struct ClearErrorOnReturn {
916- ~ClearErrorOnReturn () { ERR_clear_error (); }
917- };
918919 ClearErrorOnReturn clear_error_on_return;
919920 (void ) &clear_error_on_return; // Silence unused variable warning.
920921
@@ -3603,6 +3604,8 @@ class DiffieHellman : public ObjectWrap {
36033604 return ThrowException (Exception::Error (String::New (" Not initialized" )));
36043605 }
36053606
3607+ ClearErrorOnReturn clear_error_on_return;
3608+ (void ) &clear_error_on_return; // Silence compiler warning.
36063609 BIGNUM* key = 0 ;
36073610
36083611 if (args.Length () == 0 ) {
0 commit comments