mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Fixes topcrash 171333 crash at startup in nsFileChannel if chrome modified [@ nsFileChannel::GetFile] r=danm@netscape.com, sr=brendan@mozilla.org
This commit is contained in:
parent
8bb227628e
commit
55fd3921f7
@ -51,7 +51,7 @@
|
||||
#include "nsInt64.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "prio.h" // Need to pick up def of PR_RDONLY
|
||||
#include "prio.h" // Need to pick up def of PR_RDONLY
|
||||
|
||||
static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
|
||||
@ -259,9 +259,7 @@ nsFileChannel::EnsureFile()
|
||||
nsresult
|
||||
nsFileChannel::GetFileTransport(nsITransport **trans)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
rv = EnsureFile();
|
||||
nsresult rv = EnsureFile();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@ -458,6 +456,10 @@ nsFileChannel::SetContentCharset(const nsACString &aContentCharset)
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::GetContentLength(PRInt32 *aContentLength)
|
||||
{
|
||||
if (!mFile) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
PRInt64 size;
|
||||
rv = mFile->GetFileSize(&size);
|
||||
@ -551,8 +553,12 @@ nsFileChannel::OnStartRequest(nsIRequest* request, nsISupports* context)
|
||||
NS_ASSERTION(mRealListener, "No listener...");
|
||||
nsresult rv = NS_OK;
|
||||
if (mRealListener) {
|
||||
if (mGenerateHTMLDirs)
|
||||
{
|
||||
if (mGenerateHTMLDirs) {
|
||||
// GetFileTransport ensures that mFile is valid before calling
|
||||
// AsyncRead or AsyncWrite on the underlying transport. Since
|
||||
// these transports use |this| as the nsIRequestObserver, there
|
||||
// should be no way that mFile is null here.
|
||||
NS_ENSURE_TRUE(mFile, NS_ERROR_UNEXPECTED);
|
||||
PRBool directory;
|
||||
mFile->IsDirectory(&directory); // this stat should be cached and will not hit disk.
|
||||
if (directory) {
|
||||
@ -724,6 +730,10 @@ nsFileChannel::Init(nsIFile* file,
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::GetFile(nsIFile* *result)
|
||||
{
|
||||
nsresult rv = EnsureFile();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*result = mFile;
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user