Bug 1028588 - Fix dangerous public destructors in libjar/ - r=aklotz

This commit is contained in:
Benoit Jacob 2014-06-24 22:09:14 -04:00
parent 2b28b04041
commit b149e693e3
8 changed files with 30 additions and 21 deletions

View File

@ -59,10 +59,13 @@ class nsJAR : public nsIZipReader
// Allows nsZipReaderCache to access mOuterZipEntry
friend class nsZipReaderCache;
private:
virtual ~nsJAR();
public:
nsJAR();
virtual ~nsJAR();
NS_DEFINE_STATIC_CID_ACCESSOR( NS_ZIPREADER_CID )
@ -136,9 +139,10 @@ public:
NS_DECL_NSIZIPENTRY
nsJARItem(nsZipItem* aZipItem);
virtual ~nsJARItem() {}
private:
virtual ~nsJARItem() {}
uint32_t mSize; /* size in original file */
uint32_t mRealsize; /* inflated size */
uint32_t mCrc32;
@ -188,7 +192,6 @@ public:
NS_DECL_NSIOBSERVER
nsZipReaderCache();
virtual ~nsZipReaderCache();
nsresult ReleaseZip(nsJAR* reader);
@ -196,6 +199,8 @@ public:
protected:
virtual ~nsZipReaderCache();
mozilla::Mutex mLock;
uint32_t mCacheSize;
ZipsHashtable mZips;

View File

@ -82,11 +82,6 @@ public:
}
}
virtual ~nsJARInputThunk()
{
Close();
}
int64_t GetContentLength()
{
return mContentLength;
@ -96,6 +91,11 @@ public:
private:
virtual ~nsJARInputThunk()
{
Close();
}
bool mUsingJarCache;
nsCOMPtr<nsIZipReader> mJarReader;
nsCString mJarDirSpec;

View File

@ -27,8 +27,6 @@ class nsJARInputStream MOZ_FINAL : public nsIInputStream
memset(&mZs, 0, sizeof(z_stream));
}
~nsJARInputStream() { Close(); }
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIINPUTSTREAM
@ -40,6 +38,8 @@ class nsJARInputStream MOZ_FINAL : public nsIInputStream
const char* aDir);
private:
~nsJARInputStream() { Close(); }
nsRefPtr<nsZipHandle> mFd; // handle for reading
uint32_t mOutSize; // inflated size
uint32_t mInCrc; // CRC as provided by the zipentry

View File

@ -33,7 +33,6 @@ public:
// nsJARProtocolHandler methods:
nsJARProtocolHandler();
virtual ~nsJARProtocolHandler();
static nsJARProtocolHandler *GetSingleton();
@ -50,6 +49,8 @@ public:
void RemoteOpenFileComplete(nsIHashable *aRemoteFile, nsresult aStatus);
protected:
virtual ~nsJARProtocolHandler();
nsCOMPtr<nsIZipReaderCache> mJARCache;
nsCOMPtr<nsIMIMEService> mMimeService;

View File

@ -52,7 +52,6 @@ public:
// nsJARURI
nsJARURI();
virtual ~nsJARURI();
nsresult Init(const char *charsetHint);
nsresult FormatSpec(const nsACString &entryPath, nsACString &result,
@ -63,6 +62,8 @@ public:
nsresult SetSpecWithBase(const nsACString& aSpec, nsIURI* aBaseURL);
protected:
virtual ~nsJARURI();
// enum used in a few places to specify how .ref attribute should be handled
enum RefHandlingEnum {
eIgnoreRef,

View File

@ -95,13 +95,13 @@ class nsZipArchive
{
friend class nsZipFind;
/** destructing the object closes the archive */
~nsZipArchive();
public:
/** constructing does not open the archive. See OpenArchive() */
nsZipArchive();
/** destructing the object closes the archive */
~nsZipArchive();
/**
* OpenArchive
*

View File

@ -30,6 +30,8 @@ public:
private:
~nsZipDataStream() {}
nsCOMPtr<nsIStreamListener> mOutput;
nsCOMPtr<nsIOutputStream> mStream;
nsRefPtr<nsZipWriter> mWriter;

View File

@ -25,6 +25,12 @@
class nsZipHeader MOZ_FINAL : public nsIZipEntry
{
~nsZipHeader()
{
mExtraField = nullptr;
mLocalExtraField = nullptr;
}
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIZIPENTRY
@ -52,12 +58,6 @@ public:
{
}
~nsZipHeader()
{
mExtraField = nullptr;
mLocalExtraField = nullptr;
}
uint32_t mCRC;
uint32_t mCSize;
uint32_t mUSize;