Bug 1668926 - fix resource leakage in MsgGetFileStream. r=benc

Found by coverity. leaked_storage: Variable newFileStream going out of scope leaks the storage it points to.

CID 1137477

Differential Revision: https://phabricator.services.mozilla.com/D111547

--HG--
extra : rebase_source : 87f6ef054782ca9c3f4db289fbd342cc5c6def2e
extra : amend_source : 99e89ab70cd7ba571dfbfbc3097cff99eb7c248e
This commit is contained in:
Magnus Melin 2021-04-12 11:48:22 +03:00
Родитель 2a60a8a814
Коммит 1aaa23808b
1 изменённых файлов: 4 добавлений и 5 удалений

Просмотреть файл

@ -1273,8 +1273,7 @@ nsresult MsgCleanupTempFiles(const char* fileName, const char* extension) {
}
nsresult MsgGetFileStream(nsIFile* file, nsIOutputStream** fileStream) {
nsMsgFileStream* newFileStream = new nsMsgFileStream;
NS_ENSURE_TRUE(newFileStream, NS_ERROR_OUT_OF_MEMORY);
RefPtr<nsMsgFileStream> newFileStream = new nsMsgFileStream;
nsresult rv = newFileStream->InitWithFile(file);
if (NS_SUCCEEDED(rv))
rv = newFileStream->QueryInterface(NS_GET_IID(nsIOutputStream),
@ -1284,9 +1283,9 @@ nsresult MsgGetFileStream(nsIFile* file, nsIOutputStream** fileStream) {
nsresult MsgReopenFileStream(nsIFile* file, nsIInputStream* fileStream) {
nsMsgFileStream* msgFileStream = static_cast<nsMsgFileStream*>(fileStream);
if (msgFileStream)
if (msgFileStream) {
return msgFileStream->InitWithFile(file);
else
}
return NS_ERROR_FAILURE;
}