fix memory leaks and mismatched deletes

This commit is contained in:
bienvenu%netscape.com 1999-09-18 18:58:15 +00:00
Родитель 89f4618fd6
Коммит 128c62f010
4 изменённых файлов: 31 добавлений и 24 удалений

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

@ -1854,7 +1854,7 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, PRBool *app
} }
} }
delete [] folderName; nsAllocator::Free(folderName);
} }
break; break;
case nsMsgFilterAction::MarkRead: case nsMsgFilterAction::MarkRead:
@ -2812,6 +2812,7 @@ nsImapMailFolder::ProgressStatus(nsIImapProtocol* aProtocol,
nsString formattedString(printfString); nsString formattedString(printfString);
PR_FREEIF(progressMsg); PR_FREEIF(progressMsg);
progressMsg = nsCRT::strdup(formattedString.GetUnicode()); progressMsg = nsCRT::strdup(formattedString.GetUnicode());
PR_smprintf_free(printfString);
} }
} }

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

@ -2124,7 +2124,7 @@ void nsImapProtocol::SelectMailbox(const char *mailboxName)
commandBuffer.Append(escapedName); commandBuffer.Append(escapedName);
commandBuffer.Append("\"" CRLF); commandBuffer.Append("\"" CRLF);
delete []escapedName; nsAllocator::Free(escapedName);
nsresult res; nsresult res;
res = SendData(commandBuffer.GetBuffer()); res = SendData(commandBuffer.GetBuffer());
if (NS_FAILED(res)) return; if (NS_FAILED(res)) return;
@ -2438,8 +2438,8 @@ nsImapProtocol::FetchMessage(nsCString &messageIds,
nsresult rv = SendData(protocolString); nsresult rv = SendData(protocolString);
delete [] cCommandStr; nsAllocator::Free(cCommandStr);
delete [] cMessageIdsStr; nsAllocator::Free(cMessageIdsStr);
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
ParseIMAPandCheckForNewMail(protocolString); ParseIMAPandCheckForNewMail(protocolString);
PR_Free(protocolString); PR_Free(protocolString);
@ -2890,6 +2890,7 @@ void nsImapProtocol::ProcessMailboxUpdate(PRBool handlePossibleUndo)
} }
if (DeathSignalReceived()) if (DeathSignalReceived())
GetServerStateParser().ResetFlagInfo(0); GetServerStateParser().ResetFlagInfo(0);
PR_FREEIF(new_spec->allocatedPathName);
PR_FREEIF(new_spec); PR_FREEIF(new_spec);
} }
@ -4008,7 +4009,7 @@ nsImapProtocol::CreateUtf7ConvertedString(const char * aSourceString,
} }
delete [] unichars; delete [] unichars;
} }
PR_FREEIF(dstPtr);
return convertedString; return convertedString;
} }
@ -4510,7 +4511,7 @@ done:
rv = fileSpec->IsStreamOpen(&isOpen); rv = fileSpec->IsStreamOpen(&isOpen);
if (NS_SUCCEEDED(rv) && isOpen) if (NS_SUCCEEDED(rv) && isOpen)
fileSpec->CloseStream(); fileSpec->CloseStream();
delete [] escapedName; nsAllocator::Free(escapedName);
} }
//caller must free using PR_Free //caller must free using PR_Free
@ -4580,7 +4581,7 @@ void nsImapProtocol::OnRefreshACLForFolder(const char *mailboxName)
command.Append(escapedName); command.Append(escapedName);
command.Append("\"" CRLF); command.Append("\"" CRLF);
delete []escapedName; nsAllocator::Free(escapedName);
nsresult rv = SendData(command.GetBuffer()); nsresult rv = SendData(command.GetBuffer());
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
@ -4719,7 +4720,7 @@ void nsImapProtocol::GetMyRightsForFolder(const char *mailboxName)
command.Append(escapedName); command.Append(escapedName);
command.Append("\"" CRLF); command.Append("\"" CRLF);
delete []escapedName; nsAllocator::Free(escapedName);
nsresult rv = SendData(command.GetBuffer()); nsresult rv = SendData(command.GetBuffer());
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
@ -4737,7 +4738,7 @@ void nsImapProtocol::OnStatusForFolder(const char *mailboxName)
command.Append(escapedName); command.Append(escapedName);
command.Append("\" (UIDNEXT MESSAGES UNSEEN)" CRLF); command.Append("\" (UIDNEXT MESSAGES UNSEEN)" CRLF);
delete []escapedName; nsAllocator::Free(escapedName);
nsresult rv = SendData(command.GetBuffer()); nsresult rv = SendData(command.GetBuffer());
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
@ -5429,7 +5430,7 @@ void nsImapProtocol::CreateMailbox(const char *mailboxName)
command += escapedName; command += escapedName;
command += "\""CRLF; command += "\""CRLF;
delete []escapedName; nsAllocator::Free(escapedName);
nsresult rv = SendData(command.GetBuffer()); nsresult rv = SendData(command.GetBuffer());
if(NS_SUCCEEDED(rv)) if(NS_SUCCEEDED(rv))
@ -5447,7 +5448,7 @@ void nsImapProtocol::DeleteMailbox(const char *mailboxName)
command += " delete \""; command += " delete \"";
command += escapedName; command += escapedName;
command += "\"" CRLF; command += "\"" CRLF;
delete []escapedName; nsAllocator::Free(escapedName);
nsresult rv = SendData(command.GetBuffer()); nsresult rv = SendData(command.GetBuffer());
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
@ -5469,8 +5470,8 @@ void nsImapProtocol::RenameMailbox(const char *existingName,
command += "\" \""; command += "\" \"";
command += escapedNewName; command += escapedNewName;
command += "\"" CRLF; command += "\"" CRLF;
delete []escapedExistingName; nsAllocator::Free(escapedExistingName);
delete []escapedNewName; nsAllocator::Free(escapedNewName);
nsresult rv = SendData(command.GetBuffer()); nsresult rv = SendData(command.GetBuffer());
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
@ -5515,7 +5516,7 @@ void nsImapProtocol::Lsub(const char *mailboxPattern, PRBool addDirectoryIfNeces
// GetServerCommandTag(), // command tag // GetServerCommandTag(), // command tag
// escapedPattern); // escapedPattern);
delete []escapedPattern; nsAllocator::Free(escapedPattern);
PR_FREEIF(boxnameWithOnlineDirectory); PR_FREEIF(boxnameWithOnlineDirectory);
nsresult rv = SendData(command.GetBuffer()); nsresult rv = SendData(command.GetBuffer());
@ -5548,7 +5549,7 @@ void nsImapProtocol::List(const char *mailboxPattern, PRBool addDirectoryIfNeces
// GetServerCommandTag(), // command tag // GetServerCommandTag(), // command tag
// escapedPattern); // escapedPattern);
delete []escapedPattern; nsAllocator::Free(escapedPattern);
PR_FREEIF(boxnameWithOnlineDirectory); PR_FREEIF(boxnameWithOnlineDirectory);
nsresult rv = SendData(command.GetBuffer()); nsresult rv = SendData(command.GetBuffer());
@ -5568,7 +5569,7 @@ void nsImapProtocol::Subscribe(const char *mailboxName)
command += " subscribe \""; command += " subscribe \"";
command += escapedName; command += escapedName;
command += "\""CRLF; command += "\""CRLF;
delete []escapedName; nsAllocator::Free(escapedName);
nsresult rv = SendData(command.GetBuffer()); nsresult rv = SendData(command.GetBuffer());
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
@ -5586,7 +5587,7 @@ void nsImapProtocol::Unsubscribe(const char *mailboxName)
command += " unsubscribe \""; command += " unsubscribe \"";
command += escapedName; command += escapedName;
command += "\""CRLF; command += "\""CRLF;
delete []escapedName; nsAllocator::Free(escapedName);
nsresult rv = SendData(command.GetBuffer()); nsresult rv = SendData(command.GetBuffer());
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
@ -5636,7 +5637,7 @@ void nsImapProtocol::Copy(nsCString &messageList,
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
ParseIMAPandCheckForNewMail(protocolString.GetBuffer()); ParseIMAPandCheckForNewMail(protocolString.GetBuffer());
delete [] escapedDestination; nsAllocator::Free(escapedDestination);
} }
void nsImapProtocol::NthLevelChildList(const char* onlineMailboxPrefix, void nsImapProtocol::NthLevelChildList(const char* onlineMailboxPrefix,
@ -6096,7 +6097,7 @@ PRBool nsImapProtocol::TryToLogon()
while (!loginSucceeded && ++logonTries < 4); while (!loginSucceeded && ++logonTries < 4);
PR_FREEIF(password); PR_FREEIF(password);
PR_FREEIF(userName);
if (!loginSucceeded) if (!loginSucceeded)
{ {
m_currentBiffState = nsMsgBiffState_Unknown; m_currentBiffState = nsMsgBiffState_Unknown;

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

@ -790,6 +790,7 @@ void nsImapServerResponseParser::mailbox_list(PRBool discoveredFromLsub)
} }
nsCRT::free(boxSpec->hostName); nsCRT::free(boxSpec->hostName);
PR_FREEIF(boxSpec->allocatedPathName);
PR_FREEIF(boxSpec); // mscott - do we have any fields we need to release? PR_FREEIF(boxSpec); // mscott - do we have any fields we need to release?
} }
@ -848,8 +849,8 @@ void nsImapServerResponseParser::mailbox(mailbox_spec *boxSpec)
char *convertedName = char *convertedName =
fServerConnection.CreateUtf7ConvertedString(boxname, PR_FALSE); fServerConnection.CreateUtf7ConvertedString(boxname, PR_FALSE);
PRUnichar *unicharName; // PRUnichar *unicharName;
unicharName = fServerConnection.CreatePRUnicharStringFromUTF7(boxname); // unicharName = fServerConnection.CreatePRUnicharStringFromUTF7(boxname);
PL_strfree(boxname); PL_strfree(boxname);
boxname = convertedName; boxname = convertedName;
} }

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

@ -87,6 +87,8 @@ nsImapUrl::~nsImapUrl()
{ {
PR_FREEIF(m_listOfMessageIds); PR_FREEIF(m_listOfMessageIds);
PR_FREEIF(m_userName); PR_FREEIF(m_userName);
PR_FREEIF(m_destinationCanonicalFolderPathSubString);
PR_FREEIF(m_sourceCanonicalFolderPathSubString);
} }
NS_IMPL_ADDREF_INHERITED(nsImapUrl, nsMsgMailNewsUrl) NS_IMPL_ADDREF_INHERITED(nsImapUrl, nsMsgMailNewsUrl)
@ -1009,12 +1011,14 @@ void nsImapUrl::ParseFolderPath(char **resultingCanonicalPath)
m_validUrl = PR_FALSE; m_validUrl = PR_FALSE;
return; return;
} }
NS_ASSERTION(*resultingCanonicalPath == nsnull, "whoops, mem leak");
*resultingCanonicalPath = PL_strdup(resultPath); char dirSeparator = *resultPath;
*resultingCanonicalPath = PL_strdup(resultPath + 1);
// The delimiter will be set for a given URL, but will not be statically available // The delimiter will be set for a given URL, but will not be statically available
// from an arbitrary URL. It is the creator's responsibility to fill in the correct // from an arbitrary URL. It is the creator's responsibility to fill in the correct
// delimiter from the folder's namespace when creating the URL. // delimiter from the folder's namespace when creating the URL.
char dirSeparator = *(*resultingCanonicalPath)++;
if (dirSeparator != kOnlineHierarchySeparatorUnknown) if (dirSeparator != kOnlineHierarchySeparatorUnknown)
SetOnlineSubDirSeparator( dirSeparator); SetOnlineSubDirSeparator( dirSeparator);