Bug 1274044: Relax assertion in nsStandardURL for case when mDefaultPort is -1. r=valentin
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 19 May 2016 10:05:17 -0700
changeset 298174 385e27c898e641f03d223e87367f2a58128e35d6
parent 298173 00ad215248d56e47923c567d894cb9c94a62d470
child 298175 03ed23408215dbc98f987c68a568af89adb25eb8
push id30273
push userkwierso@gmail.com
push dateFri, 20 May 2016 21:08:12 +0000
treeherdermozilla-central@c403ac05b8f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1274044
milestone49.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 1274044: Relax assertion in nsStandardURL for case when mDefaultPort is -1. r=valentin The assertion is trying to require that the caller should never pass in mDefaultPort; instead, the caller should pass -1. BUT, if mDefaultPort is itself -1 (i.e. there's no default port), then we need to allow the caller to pass in -1 without spamming an assertion. MozReview-Commit-ID: GKxndkJoXcv
netwerk/base/nsStandardURL.cpp
netwerk/test/crashtests/1274044-1.html
netwerk/test/crashtests/crashtests.list
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -1852,17 +1852,17 @@ nsStandardURL::SetPort(int32_t port)
  *  - Calling InvalidateCache (since our mSpec is changing).
  *  - Checking whether aNewPort is mDefaultPort (in which case the
  *    caller should pass aNewPort=-1).
  */
 void
 nsStandardURL::ReplacePortInSpec(int32_t aNewPort)
 {
     MOZ_ASSERT(mMutable, "Caller should ensure we're mutable");
-    NS_ASSERTION(aNewPort != mDefaultPort,
+    NS_ASSERTION(aNewPort != mDefaultPort || mDefaultPort == -1,
                  "Caller should check its passed-in value and pass -1 instead of "
                  "mDefaultPort, to avoid encoding default port into mSpec");
 
     // Create the (possibly empty) string that we're planning to replace:
     nsAutoCString buf;
     if (mPort != -1) {
         buf.Assign(':');
         buf.AppendInt(mPort);
new file mode 100644
--- /dev/null
+++ b/netwerk/test/crashtests/1274044-1.html
@@ -0,0 +1,7 @@
+<script>
+
+var u = new URL("http://127.0.0.1:9607/");
+u.protocol = "resource:";
+u.port = "";
+
+</script>
--- a/netwerk/test/crashtests/crashtests.list
+++ b/netwerk/test/crashtests/crashtests.list
@@ -1,2 +1,3 @@
 load 785753-1.html
 load 785753-2.html
+load 1274044-1.html