зеркало из https://github.com/mozilla/pjs.git
Fixed leak in AsyncRead/AsyncWrite. r=danm
This commit is contained in:
Родитель
a0e4444da8
Коммит
6923e40b28
|
@ -203,19 +203,7 @@ nsFileIO::GetInputStream(nsIInputStream * *aInputStream)
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(fileIn);
|
||||
rv = fileIn->Init(mFile, mIOFlags, mPerm);
|
||||
if (NS_FAILED(rv)) {
|
||||
#if DEBUG
|
||||
char* filePath = nsnull;
|
||||
mFile->GetPath(&filePath);
|
||||
if (filePath)
|
||||
{
|
||||
printf("Opening %s failed\n", filePath);
|
||||
nsAllocator::Free(filePath);
|
||||
}
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
#ifdef NO_BUFFERING
|
||||
*aInputStream = fileIn;
|
||||
NS_ADDREF(*aInputStream);
|
||||
|
@ -223,8 +211,9 @@ nsFileIO::GetInputStream(nsIInputStream * *aInputStream)
|
|||
rv = NS_NewBufferedInputStream(aInputStream,
|
||||
fileIn, NS_OUTPUT_STREAM_BUFFER_SIZE);
|
||||
#endif
|
||||
}
|
||||
NS_RELEASE(fileIn);
|
||||
|
||||
// printf("opening %s for reading\n", mSpec);
|
||||
PR_LOG(gFileIOLog, PR_LOG_DEBUG,
|
||||
("nsFileIO: opening local file %s for input (%x)",
|
||||
mSpec, rv));
|
||||
|
@ -246,21 +235,18 @@ nsFileIO::GetOutputStream(nsIOutputStream * *aOutputStream)
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(fileOut);
|
||||
rv = fileOut->Init(mFile, mIOFlags, mPerm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIOutputStream> bufStr;
|
||||
#ifdef NO_BUFFERING
|
||||
bufStr = fileOut;
|
||||
#else
|
||||
rv = NS_NewBufferedOutputStream(getter_AddRefs(bufStr),
|
||||
fileOut, NS_OUTPUT_STREAM_BUFFER_SIZE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#endif
|
||||
|
||||
*aOutputStream = bufStr;
|
||||
*aOutputStream = fileOut;
|
||||
NS_ADDREF(*aOutputStream);
|
||||
#else
|
||||
rv = NS_NewBufferedOutputStream(aOutputStream,
|
||||
fileOut, NS_OUTPUT_STREAM_BUFFER_SIZE);
|
||||
#endif
|
||||
}
|
||||
NS_RELEASE(fileOut);
|
||||
|
||||
// printf("opening %s for writing\n", mSpec);
|
||||
PR_LOG(gFileIOLog, PR_LOG_DEBUG,
|
||||
("nsFileIO: opening local file %s for output (%x)",
|
||||
mSpec, rv));
|
||||
|
|
Загрузка…
Ссылка в новой задаче