Bug 400322 "ASSERTION: nsStandardURL not thread-safe" (nsJARInputThunk marked as threadsafe uses nsJARURI in a non threadsafe manner), r+sr=biesi
authortimeless@mozdev.org
Sun, 01 Mar 2009 17:06:55 -0800
changeset 25656 4c8363cef88b7dee845c1d0046023367aba29401
parent 25655 d292ca6cf27b445f17e8a7d2f7f17b53396fa6ef
child 25657 151cf0a020b0c295f38da5e4eb022acb94ee67ec
push id5667
push userphilringnalda@gmail.com
push dateMon, 02 Mar 2009 01:07:41 +0000
treeherdermozilla-central@151cf0a020b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs400322
milestone1.9.2a1pre
Bug 400322 "ASSERTION: nsStandardURL not thread-safe" (nsJARInputThunk marked as threadsafe uses nsJARURI in a non threadsafe manner), r+sr=biesi
modules/libjar/nsJARChannel.cpp
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -85,21 +85,25 @@ public:
     NS_DECL_NSIINPUTSTREAM
 
     nsJARInputThunk(nsIFile *jarFile,
                     nsIURI* fullJarURI,
                     const nsACString &jarEntry,
                     nsIZipReaderCache *jarCache)
         : mJarCache(jarCache)
         , mJarFile(jarFile)
-        , mFullJarURI(fullJarURI)
         , mJarEntry(jarEntry)
         , mContentLength(-1)
     {
         NS_ASSERTION(mJarFile, "no jar file");
+
+        if (fullJarURI) {
+            nsresult rv = fullJarURI->GetAsciiSpec(mJarDirSpec);
+            NS_ASSERTION(NS_SUCCEEDED(rv), "this shouldn't fail");
+        }
     }
 
     virtual ~nsJARInputThunk()
     {
         if (!mJarCache && mJarReader)
             mJarReader->Close();
     }
 
@@ -115,17 +119,17 @@ public:
 
     nsresult EnsureJarStream();
 
 private:
 
     nsCOMPtr<nsIZipReaderCache> mJarCache;
     nsCOMPtr<nsIZipReader>      mJarReader;
     nsCOMPtr<nsIFile>           mJarFile;
-    nsCOMPtr<nsIURI>            mFullJarURI;
+    nsCString                   mJarDirSpec;
     nsCOMPtr<nsIInputStream>    mJarStream;
     nsCString                   mJarEntry;
     PRInt32                     mContentLength;
 };
 
 NS_IMPL_THREADSAFE_ISUPPORTS1(nsJARInputThunk, nsIInputStream)
 
 nsresult
@@ -145,21 +149,19 @@ nsJARInputThunk::EnsureJarStream()
         rv = mJarReader->Open(mJarFile);
     }
     if (NS_FAILED(rv)) return rv;
 
     if (ENTRY_IS_DIRECTORY(mJarEntry)) {
         // A directory stream also needs the Spec of the FullJarURI
         // because is included in the stream data itself.
 
-        nsCAutoString jarDirSpec;
-        rv = mFullJarURI->GetAsciiSpec(jarDirSpec);
-        if (NS_FAILED(rv)) return rv;
+        NS_ENSURE_STATE(!mJarDirSpec.IsEmpty());
 
-        rv = mJarReader->GetInputStreamWithSpec(jarDirSpec,
+        rv = mJarReader->GetInputStreamWithSpec(mJarDirSpec,
                                                 mJarEntry.get(),
                                                 getter_AddRefs(mJarStream));
     }
     else {
         rv = mJarReader->GetInputStream(mJarEntry.get(),
                                         getter_AddRefs(mJarStream));
     }
     if (NS_FAILED(rv)) {