Bug 1336510 - Part 5: Workaround lambda static analysis in nsMultiMixedConv, r=valentin
☠☠ backed out by 3fee518242f6 ☠ ☠
authorMichael Layzell <michael@thelayzells.com>
Tue, 14 Feb 2017 14:40:26 -0500
changeset 373643 21869174dfd3e1548324f590245ea06d215a5d6a
parent 373642 57476b9f342d8872813e701261fad2907738c969
child 373644 422e63b872b5284a2f31cfaf36c1853a8f636a75
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1336510
milestone54.0a1
Bug 1336510 - Part 5: Workaround lambda static analysis in nsMultiMixedConv, r=valentin MozReview-Commit-ID: 7Mvh9aeCKOh
netwerk/streamconv/converters/nsMultiMixedConv.cpp
--- a/netwerk/streamconv/converters/nsMultiMixedConv.cpp
+++ b/netwerk/streamconv/converters/nsMultiMixedConv.cpp
@@ -802,19 +802,24 @@ nsMultiMixedConv::SwitchToControlParsing
     mTokenizer.EnableCustomToken(mBoundaryTokenWithDashes, false);
     mTokenizer.EnableCustomToken(mBoundaryToken, false);
 }
 
 // nsMultiMixedConv methods
 nsMultiMixedConv::nsMultiMixedConv() :
     mCurrentPartID(0),
     mInOnDataAvailable(false),
-    mTokenizer([this](Token const& token, mozilla::IncrementalTokenizer&) -> nsresult {
-        return this->ConsumeToken(token);
-    })
+    // XXX: This is a hack to bypass the raw pointer to refcounted object in
+    // lambda analysis. It should be removed and replaced when the
+    // IncrementalTokenizer API is improved to avoid the need for such
+    // workarounds.
+    //
+    // This is safe because `mTokenizer` will not outlive `this`, meaning that
+    // this std::bind object will be destroyed before `this` dies.
+    mTokenizer(std::bind(&nsMultiMixedConv::ConsumeToken, this, std::placeholders::_1))
 {
     mContentLength      = UINT64_MAX;
     mByteRangeStart     = 0;
     mByteRangeEnd       = 0;
     mTotalSent          = 0;
     mIsByteRangeRequest = false;
     mParserState        = INIT;
     mRawData            = nullptr;