Bug 1035394 - Fix dangerous public destructors in netwerk - r=mcmanus

This commit is contained in:
Benoit Jacob 2014-07-08 17:23:18 -04:00
parent 4bcd57abcb
commit c517b3dd2b
8 changed files with 47 additions and 18 deletions

View File

@ -71,7 +71,6 @@ public:
NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM
nsBufferedInputStream() : nsBufferedStream() {}
virtual ~nsBufferedInputStream() {}
static nsresult
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
@ -81,6 +80,8 @@ public:
}
protected:
virtual ~nsBufferedInputStream() {}
NS_IMETHOD Fill();
NS_IMETHOD Flush() { return NS_OK; } // no-op for input streams
};
@ -100,7 +101,6 @@ public:
NS_DECL_NSISTREAMBUFFERACCESS
nsBufferedOutputStream() : nsBufferedStream() {}
virtual ~nsBufferedOutputStream() { nsBufferedOutputStream::Close(); }
static nsresult
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
@ -110,6 +110,8 @@ public:
}
protected:
virtual ~nsBufferedOutputStream() { nsBufferedOutputStream::Close(); }
NS_IMETHOD Fill() { return NS_OK; } // no-op for output streams
nsCOMPtr<nsISafeOutputStream> mSafeStream; // QI'd from mStream

View File

@ -134,15 +134,15 @@ public:
: mLineBuffer(nullptr), mIOFlags(0), mPerm(0), mCachedPosition(0)
{}
static nsresult
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
protected:
virtual ~nsFileInputStream()
{
Close();
}
static nsresult
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
protected:
nsAutoPtr<nsLineBuffer<char> > mLineBuffer;
/**
@ -195,6 +195,10 @@ public:
static nsresult
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
protected:
~nsPartialFileInputStream()
{ }
private:
uint64_t TruncateSize(uint64_t aSize) {
return std::min<uint64_t>(mLength - mPosition, aSize);
@ -215,13 +219,14 @@ public:
NS_DECL_NSIFILEOUTPUTSTREAM
NS_FORWARD_NSIOUTPUTSTREAM(nsFileStreamBase::)
static nsresult
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
protected:
virtual ~nsFileOutputStream()
{
Close();
}
static nsresult
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
};
////////////////////////////////////////////////////////////////////////////////
@ -242,11 +247,6 @@ public:
mTargetFileExists(true),
mWriteResult(NS_OK) {}
virtual ~nsAtomicFileOutputStream()
{
Close();
}
virtual nsresult DoOpen() MOZ_OVERRIDE;
NS_IMETHODIMP Close();
@ -254,6 +254,11 @@ public:
NS_IMETHODIMP Init(nsIFile* file, int32_t ioFlags, int32_t perm, int32_t behaviorFlags);
protected:
virtual ~nsAtomicFileOutputStream()
{
Close();
}
nsCOMPtr<nsIFile> mTargetFile;
nsCOMPtr<nsIFile> mTempFile;
@ -311,6 +316,7 @@ public:
_retval);
}
protected:
virtual ~nsFileStream()
{
Close();

View File

@ -70,10 +70,12 @@ public:
nsILoadContextInfo* aLoadInfo,
bool aWriteToDisk,
uint32_t aFlags);
virtual ~_OldCacheLoad();
nsresult Start();
protected:
virtual ~_OldCacheLoad();
private:
void Check();

View File

@ -14,11 +14,13 @@ public:
NS_DECL_ISUPPORTS_INHERITED
nsDeviceChannel();
~nsDeviceChannel();
nsresult Init(nsIURI* uri);
nsresult OpenContentStream(bool aAsync,
nsIInputStream **aStream,
nsIChannel **aChannel);
protected:
~nsDeviceChannel();
};
#endif

View File

@ -184,6 +184,14 @@ private:
nsCOMPtr<nsITransportEventSink> mSink;
};
namespace mozilla {
template<>
struct HasDangerousPublicDestructor<nsFileUploadContentStream>
{
static const bool value = true;
};
}
NS_IMPL_ISUPPORTS_INHERITED0(nsFileUploadContentStream,
nsBaseContentStream)
@ -269,6 +277,10 @@ nsFileChannel::nsFileChannel(nsIURI *uri)
}
}
nsFileChannel::~nsFileChannel()
{
}
nsresult
nsFileChannel::MakeFileInputStream(nsIFile *file,
nsCOMPtr<nsIInputStream> &stream,

View File

@ -23,6 +23,8 @@ public:
nsFileChannel(nsIURI *uri);
protected:
~nsFileChannel();
// Called to construct a blocking file input stream for the given file. This
// method also returns a best guess at the content-type for the data stream.
// NOTE: If the channel has a type hint set, contentType will be left

View File

@ -54,7 +54,6 @@ public:
NS_IMETHOD Resume();
FTPChannelChild(nsIURI* uri);
virtual ~FTPChannelChild();
void AddIPDLReference();
void ReleaseIPDLReference();
@ -74,6 +73,8 @@ public:
void FlushedForDiversion();
protected:
virtual ~FTPChannelChild();
bool RecvOnStartRequest(const nsresult& aChannelStatus,
const int64_t& aContentLength,
const nsCString& aContentType,

View File

@ -91,7 +91,6 @@ public:
NS_IMETHOD GetRequestMethod(nsACString& aMethod);
nsHttpChannel();
virtual ~nsHttpChannel();
virtual nsresult Init(nsIURI *aURI, uint32_t aCaps, nsProxyInfo *aProxyInfo,
uint32_t aProxyResolveFlags,
@ -188,6 +187,9 @@ public: /* internal necko use only */
uint32_t mKeep : 2;
};
protected:
virtual ~nsHttpChannel();
private:
typedef nsresult (nsHttpChannel::*nsContinueRedirectionFunc)(nsresult result);