don't allow thread unread counts to be negative r=naving, sr=mscott fixes one case of 64476

This commit is contained in:
bienvenu%netscape.com 2001-07-20 13:13:32 +00:00
Родитель 7a819a744f
Коммит 0acb8185bc
1 изменённых файлов: 16 добавлений и 8 удалений

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

@ -94,6 +94,8 @@ nsresult nsMsgThread::InitCachedValues()
// NS_ASSERTION(m_numChildren <= rowCount, "num children wrong - fixing");
if (m_numChildren > rowCount)
ChangeChildCount((PRInt32) rowCount - (PRInt32) m_numChildren);
if ((PRInt32) m_numUnreadChildren < 0)
ChangeUnreadChildCount(- (PRInt32) m_numUnreadChildren);
if (NS_SUCCEEDED(err))
m_cachedValuesInitialized = PR_TRUE;
}
@ -963,7 +965,13 @@ nsresult nsMsgThread::ChangeUnreadChildCount(PRInt32 delta)
PRUint32 childCount = 0;
m_mdbDB->RowCellColumnToUInt32(m_metaRow, m_mdbDB->m_threadUnreadChildrenColumnToken, childCount);
childCount += delta;
if ((PRInt32) childCount < 0)
{
#ifdef DEBUG_bienvenu
NS_ASSERTION(PR_FALSE, "negative unread child count");
#endif
childCount = 0;
}
ret = m_mdbDB->UInt32ToRowCellColumn(m_metaRow, m_mdbDB->m_threadUnreadChildrenColumnToken, childCount);
m_numUnreadChildren = childCount;
return ret;