diff --git a/mozilla/calendar/modules/core/src/nsCalSessionMgr.cpp b/mozilla/calendar/modules/core/src/nsCalSessionMgr.cpp index e4ba3a4db2c..a65640f3c6f 100644 --- a/mozilla/calendar/modules/core/src/nsCalSessionMgr.cpp +++ b/mozilla/calendar/modules/core/src/nsCalSessionMgr.cpp @@ -254,6 +254,9 @@ nsresult nsCalSessionMgr::Find(CAPISession s, int iStart, int* piFound) */ nsCalSession* nsCalSessionMgr::GetAt(int i) { + if (m_List.GetSize() == 0) + return nsnull; + return (nsCalSession*) m_List.GetAt(i); } diff --git a/mozilla/calendar/modules/core/src/nsCalendarUser.cpp b/mozilla/calendar/modules/core/src/nsCalendarUser.cpp index a4459726a22..ebb8c640520 100644 --- a/mozilla/calendar/modules/core/src/nsCalendarUser.cpp +++ b/mozilla/calendar/modules/core/src/nsCalendarUser.cpp @@ -118,6 +118,8 @@ nsresult nsCalendarUser::Init() if (NS_OK == res) mpLayer->Init(); + NS_RELEASE(supports); + return res; } @@ -131,7 +133,9 @@ NS_IMETHODIMP nsCalendarUser :: GetLayer(nsILayer *& aLayer) NS_IMETHODIMP nsCalendarUser :: SetLayer(nsILayer* aLayer) { + NS_IF_RELEASE(mpLayer); mpLayer = aLayer; + NS_ADDREF(mpLayer); return NS_OK; } diff --git a/mozilla/calendar/modules/shell/src/nsCalendarContainer.cpp b/mozilla/calendar/modules/shell/src/nsCalendarContainer.cpp index 1163862b35a..0b20f01e345 100644 --- a/mozilla/calendar/modules/shell/src/nsCalendarContainer.cpp +++ b/mozilla/calendar/modules/shell/src/nsCalendarContainer.cpp @@ -604,6 +604,7 @@ nsresult nsCalendarContainer::LoadURL(const nsString& aURLSpec, pLayer->Init(); pLayer->SetCurl(theURL.GetCurl()); caluser->SetLayer(pLayer); + NS_RELEASE(pLayer); /* @@ -630,6 +631,7 @@ nsresult nsCalendarContainer::LoadURL(const nsString& aURLSpec, pLayer->SetShell(shell); pLayer->FetchEventsByRange(&d,&d1,&EventList); pCalendar->addEventList(&EventList); + NS_RELEASE(pLayer); } break; diff --git a/mozilla/calendar/modules/shell/src/nsCalendarShell.cpp b/mozilla/calendar/modules/shell/src/nsCalendarShell.cpp index 3bd9e44002d..8661fafda2d 100644 --- a/mozilla/calendar/modules/shell/src/nsCalendarShell.cpp +++ b/mozilla/calendar/modules/shell/src/nsCalendarShell.cpp @@ -134,16 +134,19 @@ nsCalendarShell::nsCalendarShell() nsCalendarShell::~nsCalendarShell() { - mSessionMgr.GetAt(0L)->mCapi->CAPI_DestroyHandles(mCAPISession, &mCAPIHandle, 1, 0L); + nsCalSession * session = mSessionMgr.GetAt(0L); + + if (session != nsnull) + session->mCapi->CAPI_DestroyHandles(mCAPISession, &mCAPIHandle, 1, 0L); + Logoff(); NS_IF_RELEASE(mObserverManager); if (mCAPIPassword) PR_Free(mCAPIPassword); - if (mpLoggedInUser) - delete mpLoggedInUser; + NS_IF_RELEASE(mpLoggedInUser); NS_IF_RELEASE(mDocumentContainer); NS_IF_RELEASE(mShellInstance); NS_IF_RELEASE(mCommandServer);