Bug 1145812 - Fix assertion with dom.url.encode_decode_hash pref set to true r=mcmanus
authorValentin Gosu <valentin.gosu@gmail.com>
Mon, 23 Mar 2015 23:28:50 +0200
changeset 264006 21695668595dc62c662ea2c84489e5237aa700d9
parent 264005 a7e0ef41f518d91f456e6e2ee1a16ee7d1d045da
child 264007 55e5147d448ee5ab3a017017402f7926bd5219e2
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1145812
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1145812 - Fix assertion with dom.url.encode_decode_hash pref set to true r=mcmanus
netwerk/base/nsStandardURL.cpp
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -2509,19 +2509,21 @@ nsStandardURL::SetRef(const nsACString &
     
     if (mRef.mLen < 0) {
         mSpec.Append('#');
         ++mPath.mLen;  // Include the # in the path.
         mRef.mPos = mSpec.Length();
         mRef.mLen = 0;
     }
 
+    // If precent encoding is necessary, `ref` will point to `buf`'s content.
+    // `buf` needs to outlive any use of the `ref` pointer.
+    nsAutoCString buf;
     if (nsContentUtils::EncodeDecodeURLHash()) {
         // encode ref if necessary
-        nsAutoCString buf;
         bool encoded;
         GET_SEGMENT_ENCODER(encoder);
         encoder.EncodeSegmentCount(ref, URLSegment(0, refLen), esc_Ref,
                                    buf, encoded);
         if (encoded) {
             ref = buf.get();
             refLen = buf.Length();
         }