Bug 1009648: Fix windows crash when removing from linked list r=mcmanus
authorValentin Gosu <valentin.gosu@gmail.com>
Sat, 09 Aug 2014 06:59:00 +0300
changeset 198843 ffe2d5537d2d83f3eb991b24fa21aac1c9529262
parent 198842 f7ff242d4af8dc532e0bf27f091668313f632c35
child 198844 ce924184d6b1fcfe9e68a28fc07fb831c58e8fe1
push id47503
push uservalentin.gosu@gmail.com
push dateMon, 11 Aug 2014 09:14:50 +0000
treeherdermozilla-inbound@ffe2d5537d2d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1009648
milestone34.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 1009648: Fix windows crash when removing from linked list r=mcmanus
netwerk/base/src/nsStandardURL.cpp
netwerk/base/src/nsStandardURL.h
--- a/netwerk/base/src/nsStandardURL.cpp
+++ b/netwerk/base/src/nsStandardURL.cpp
@@ -239,17 +239,17 @@ nsSegmentEncoder::InitUnicodeEncoder()
 //----------------------------------------------------------------------------
 // nsStandardURL <public>
 //----------------------------------------------------------------------------
 
 #ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
 static PRCList gAllURLs;
 #endif
 
-nsStandardURL::nsStandardURL(bool aSupportsFileURL)
+nsStandardURL::nsStandardURL(bool aSupportsFileURL, bool aTrackURL)
     : mDefaultPort(-1)
     , mPort(-1)
     , mHostA(nullptr)
     , mHostEncoding(eEncoding_ASCII)
     , mSpecEncoding(eEncoding_Unknown)
     , mURLType(URLTYPE_STANDARD)
     , mMutable(true)
     , mSupportsFileURL(aSupportsFileURL)
@@ -265,29 +265,35 @@ nsStandardURL::nsStandardURL(bool aSuppo
         gInitialized = true;
         InitGlobalObjects();
     }
 
     // default parser in case nsIStandardURL::Init is never called
     mParser = net_GetStdURLParser();
 
 #ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
-    PR_APPEND_LINK(&mDebugCList, &gAllURLs);
+    if (aTrackURL) {
+        PR_APPEND_LINK(&mDebugCList, &gAllURLs);
+    } else {
+        PR_INIT_CLIST(&mDebugCList);
+    }
 #endif
 }
 
 nsStandardURL::~nsStandardURL()
 {
     LOG(("Destroying nsStandardURL @%p\n", this));
 
     if (mHostA) {
         free(mHostA);
     }
 #ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
-    PR_REMOVE_LINK(&mDebugCList);
+    if (!PR_CLIST_IS_EMPTY(&mDebugCList)) {
+        PR_REMOVE_LINK(&mDebugCList);
+    }
 #endif
 }
 
 #ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
 struct DumpLeakedURLs {
     DumpLeakedURLs() {}
     ~DumpLeakedURLs();
 };
@@ -1134,17 +1140,17 @@ nsStandardURL::SetSpec(const nsACString 
     int32_t specLength = flat.Length();
 
     LOG(("nsStandardURL::SetSpec [spec=%s]\n", spec));
 
     if (!spec || !*spec)
         return NS_ERROR_MALFORMED_URI;
 
     // Make a backup of the curent URL
-    nsStandardURL prevURL;
+    nsStandardURL prevURL(false,false);
     prevURL.CopyMembers(this, eHonorRef);
     Clear();
 
     // filter out unexpected chars "\r\n\t" if necessary
     nsAutoCString buf1;
     if (net_FilterURIString(spec, buf1)) {
         spec = buf1.get();
         specLength = buf1.Length();
--- a/netwerk/base/src/nsStandardURL.h
+++ b/netwerk/base/src/nsStandardURL.h
@@ -56,17 +56,17 @@ public:
     NS_DECL_NSICLASSINFO
     NS_DECL_NSIMUTABLE
     NS_DECL_NSIIPCSERIALIZABLEURI
 
     // nsISizeOf
     virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
     virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
-    explicit nsStandardURL(bool aSupportsFileURL = false);
+    explicit nsStandardURL(bool aSupportsFileURL = false, bool aTrackURL = true);
 
     static void InitGlobalObjects();
     static void ShutdownGlobalObjects();
 
 public: /* internal -- HPUX compiler can't handle this being private */
     //
     // location and length of an url segment relative to mSpec
     //