Bug 1351270 - [Coverity 1403257] Don't let ssl_gtests throw exceptions in destructors r=mt
authorTim Taubert <ttaubert@mozilla.com>
Tue, 28 Mar 2017 16:33:09 +0200
changeset 13261 215207b4864c
parent 13260 c8651a146092
child 13262 1fb7e5f584de
push id2127
push userttaubert@mozilla.com
push dateTue, 28 Mar 2017 14:34:24 +0000
reviewersmt
bugs1351270, 1403257
Bug 1351270 - [Coverity 1403257] Don't let ssl_gtests throw exceptions in destructors r=mt Differential Revision: https://nss-review.dev.mozaws.net/D281
gtests/ssl_gtest/tls_agent.cc
--- a/gtests/ssl_gtest/tls_agent.cc
+++ b/gtests/ssl_gtest/tls_agent.cc
@@ -84,20 +84,25 @@ TlsAgent::~TlsAgent() {
   if (timer_handle_) {
     timer_handle_->Cancel();
   }
 
   if (adapter_) {
     Poller::Instance()->Cancel(READABLE_EVENT, adapter_);
   }
 
-  EXPECT_EQ(expected_received_alert_, kTlsAlertCloseNotify);
-  EXPECT_EQ(expected_received_alert_level_, kTlsAlertWarning);
-  EXPECT_EQ(expected_sent_alert_, kTlsAlertCloseNotify);
-  EXPECT_EQ(expected_sent_alert_level_, kTlsAlertWarning);
+  // Add failures manually, if any, so we don't throw in a destructor.
+  if (expected_received_alert_ != kTlsAlertCloseNotify ||
+      expected_received_alert_level_ != kTlsAlertWarning) {
+    ADD_FAILURE() << "Wrong expected_received_alert status";
+  }
+  if (expected_sent_alert_ != kTlsAlertCloseNotify ||
+      expected_sent_alert_level_ != kTlsAlertWarning) {
+    ADD_FAILURE() << "Wrong expected_sent_alert status";
+  }
 }
 
 void TlsAgent::SetState(State state) {
   if (state_ == state) return;
 
   LOG("Changing state from " << state_ << " to " << state);
   state_ = state;
 }