From 3571ed761abbe288e918e5a64b81cf6c2da8ed33 Mon Sep 17 00:00:00 2001 From: Fedor Date: Sun, 7 Feb 2021 17:33:42 +0200 Subject: [PATCH] [network] Hold mutex when accessing mSecurityInfo. --- netwerk/protocol/http/nsHttpTransaction.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp index e7f3ca0ef..9c5895cb0 100644 --- a/netwerk/protocol/http/nsHttpTransaction.cpp +++ b/netwerk/protocol/http/nsHttpTransaction.cpp @@ -765,7 +765,10 @@ nsHttpTransaction::ReadSegments(nsAHttpSegmentReader *reader, if (!mConnected && !m0RTTInProgress) { mConnected = true; - mConnection->GetSecurityInfo(getter_AddRefs(mSecurityInfo)); + nsCOMPtr info; + mConnection->GetSecurityInfo(getter_AddRefs(info)); + MutexAutoLock lock(mLock); + mSecurityInfo = std::move(info); } mDeferredSendProgress = false; @@ -1314,7 +1317,10 @@ nsHttpTransaction::Restart() seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0); // clear old connection state... - mSecurityInfo = nullptr; + { + MutexAutoLock lock(mLock); + mSecurityInfo = nullptr; + } if (mConnection) { if (!mReuseOnRestart) { mConnection->DontReuse(); @@ -2489,7 +2495,10 @@ nsHttpTransaction::Finish0RTT(bool aRestart, bool aAlpnChanged /* ignored */) } else if (!mConnected) { // this is code that was skipped in ::ReadSegments while in 0RTT mConnected = true; - mConnection->GetSecurityInfo(getter_AddRefs(mSecurityInfo)); + nsCOMPtr info; + mConnection->GetSecurityInfo(getter_AddRefs(info)); + MutexAutoLock lock(mLock); + mSecurityInfo = std::move(info); } return NS_OK; }