Bug #336737 --> crash when switching folders [@NS_strlen]

patch by bienvenu
sr=mscott
This commit is contained in:
scott%scott-macgregor.org 2006-05-15 18:20:12 +00:00
Родитель 6f0e67928a
Коммит 90781c7bc8
2 изменённых файлов: 21 добавлений и 13 удалений

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

@ -502,15 +502,15 @@ nsresult nsMsgDBView::FetchAuthor(nsIMsgDBHdr * aHdr, PRUnichar ** aSenderString
{
nsXPIDLCString name;
rv = mHeaderParser->ExtractHeaderAddressName("UTF-8", NS_ConvertUTF16toUTF8(unparsedAuthor).get(), getter_Copies(name));
if (NS_SUCCEEDED(rv) && (const char*)name)
if (NS_SUCCEEDED(rv) && !name.IsEmpty())
{
*aSenderString = nsCRT::strdup(NS_ConvertUTF8toUTF16(name).get());
return NS_OK;
return (*aSenderString) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
}
// if we got here then just return the original string
*aSenderString = nsCRT::strdup(unparsedAuthor);
return NS_OK;
*aSenderString = nsCRT::strdup(unparsedAuthor.IsEmpty() ? NS_LITERAL_STRING("").get() : unparsedAuthor.get());
return (*aSenderString) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
nsresult nsMsgDBView::FetchAccount(nsIMsgDBHdr * aHdr, PRUnichar ** aAccount)
@ -1581,7 +1581,8 @@ NS_IMETHODIMP nsMsgDBView::GetCellText(PRInt32 aRow, nsITreeColumn* aCol, nsAStr
msgHdr->GetFlags(&flags);
rv = FetchStatus(flags, getter_Copies(valueText));
}
aValue.Assign(valueText);
if (NS_SUCCEEDED(rv))
aValue.Assign(valueText);
break;
case 'r': // recipient
rv = FetchRecipients(msgHdr, getter_Copies(valueText));

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

@ -101,7 +101,10 @@ void nsMsgGroupView::InternalClose()
{
nsHashKey *hashKey = AllocHashKeyForHdr(msgHdr);
if (hashKey)
{
expandFlags |= 1 << ((nsPRUint32Key *)hashKey)->GetValue();
delete hashKey;
}
}
}
}
@ -122,6 +125,8 @@ nsHashKey *nsMsgGroupView::AllocHashKeyForHdr(nsIMsgDBHdr *msgHdr)
{
static nsXPIDLCString cStringKey;
static nsXPIDLString stringKey;
nsresult rv;
switch (m_sortType)
{
case nsMsgViewSortType::bySubject:
@ -129,8 +134,8 @@ nsHashKey *nsMsgGroupView::AllocHashKeyForHdr(nsIMsgDBHdr *msgHdr)
return new nsCStringKey(cStringKey.get());
break;
case nsMsgViewSortType::byAuthor:
(void) nsMsgDBView::FetchAuthor(msgHdr, getter_Copies(stringKey));
return new nsStringKey(stringKey.get());
rv = nsMsgDBView::FetchAuthor(msgHdr, getter_Copies(stringKey));
return NS_SUCCEEDED(rv) ? new nsStringKey(stringKey.get()) : nsnull;
case nsMsgViewSortType::byRecipient:
(void) msgHdr->GetRecipients(getter_Copies(cStringKey));
return new nsCStringKey(cStringKey.get());
@ -141,8 +146,8 @@ nsHashKey *nsMsgGroupView::AllocHashKeyForHdr(nsIMsgDBHdr *msgHdr)
if (!dbToUse) // probably search view
GetDBForViewIndex(0, getter_AddRefs(dbToUse));
(void) FetchAccount(msgHdr, getter_Copies(stringKey));
return new nsStringKey (stringKey.get());
rv = FetchAccount(msgHdr, getter_Copies(stringKey));
return NS_SUCCEEDED(rv) ? new nsStringKey(stringKey.get()) : nsnull;
}
break;
@ -273,6 +278,8 @@ nsMsgGroupThread *nsMsgGroupView::AddHdrToThread(nsIMsgDBHdr *msgHdr, PRBool *pN
msgHdr->GetMessageKey(&msgKey);
msgHdr->GetFlags(&msgFlags);
nsHashKey *hashKey = AllocHashKeyForHdr(msgHdr);
if (!hashKey)
return nsnull;
// if (m_sortType == nsMsgViewSortType::byDate)
// msgKey = ((nsPRUint32Key *) hashKey)->GetValue();
nsMsgGroupThread *foundThread = nsnull;
@ -747,11 +754,11 @@ nsresult nsMsgGroupView::GetThreadContainingMsgHdr(nsIMsgDBHdr *msgHdr, nsIMsgTh
nsHashKey *hashKey = AllocHashKeyForHdr(msgHdr);
if (hashKey)
{
nsMsgGroupThread *groupThread = (nsMsgGroupThread *) m_groupsTable.Get(hashKey);
nsMsgGroupThread *groupThread = (nsMsgGroupThread *) m_groupsTable.Get(hashKey);
if (groupThread)
groupThread->QueryInterface(NS_GET_IID(nsIMsgThread), (void **) pThread);
delete hashKey;
if (groupThread)
groupThread->QueryInterface(NS_GET_IID(nsIMsgThread), (void **) pThread);
delete hashKey;
}
else
*pThread = nsnull;