From 2da5458bd895fae89ccb4fc58c655a66b614b3a2 Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Tue, 8 Jan 2002 01:32:27 +0000 Subject: [PATCH] add some bulletproofing to the subscribe search view so that we check the row. fixes crasher bug #117065 r/sr=bienvenu --- mailnews/news/src/nsNntpIncomingServer.cpp | 12 ++++++++++++ mailnews/news/src/nsNntpIncomingServer.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mailnews/news/src/nsNntpIncomingServer.cpp b/mailnews/news/src/nsNntpIncomingServer.cpp index 7eb7894b7e15..fa53f154703c 100644 --- a/mailnews/news/src/nsNntpIncomingServer.cpp +++ b/mailnews/news/src/nsNntpIncomingServer.cpp @@ -1775,6 +1775,9 @@ nsNntpIncomingServer::GetRowProperties(PRInt32 index, nsISupportsArray *properti NS_IMETHODIMP nsNntpIncomingServer::GetCellProperties(PRInt32 row, const PRUnichar *colID, nsISupportsArray *properties) { + if (!IsValidRow(row)) + return NS_ERROR_UNEXPECTED; + if (colID[0] == 's') { // if is in our temporary list of subscribed groups // add the "subscribed" property so the check mark shows up @@ -1868,9 +1871,18 @@ nsNntpIncomingServer::GetLevel(PRInt32 index, PRInt32 *_retval) return NS_OK; } +nsresult +nsNntpIncomingServer::IsValidRow(PRInt32 row) +{ + return ((row >= 0) && (row < mSubscribeSearchResult.Count())); +} + NS_IMETHODIMP nsNntpIncomingServer::GetCellText(PRInt32 row, const PRUnichar *colID, nsAString& _retval) { + if (!IsValidRow(row)) + return NS_ERROR_UNEXPECTED; + if (colID[0] == 'n') { nsCString str; mSubscribeSearchResult.CStringAt(row, str); diff --git a/mailnews/news/src/nsNntpIncomingServer.h b/mailnews/news/src/nsNntpIncomingServer.h index 02366a2cb199..afed83b2b6cd 100644 --- a/mailnews/news/src/nsNntpIncomingServer.h +++ b/mailnews/news/src/nsNntpIncomingServer.h @@ -154,7 +154,8 @@ private: nsCOMPtr mInner; nsresult EnsureInner(); nsresult ClearInner(); - + nsresult IsValidRow(PRInt32 row); + nsIOFileStream *mHostInfoStream; nsCOMPtr mNewsrcFilePath; };