From c1954acb738dd7f41f2c67bfd5fa8d98c435fff1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 15 Mar 2015 21:44:43 +0000 Subject: fix for processing NULL event handles git-svn-id: http://svn.miranda-ng.org/main/trunk@12411 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dbx_mdb/src/dbevents.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'plugins/Dbx_mdb/src') diff --git a/plugins/Dbx_mdb/src/dbevents.cpp b/plugins/Dbx_mdb/src/dbevents.cpp index c0a507f5d3..d42975e698 100644 --- a/plugins/Dbx_mdb/src/dbevents.cpp +++ b/plugins/Dbx_mdb/src/dbevents.cpp @@ -247,6 +247,8 @@ void CDbxMdb::FindNextUnread(const txn_ptr &txn, DBCachedContact *cc, DBEventSor STDMETHODIMP_(BOOL) CDbxMdb::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) { + if (hDbEvent == 0) return -1; + DBCachedContact *cc = m_cache->GetCachedContact(contactID); if (cc == NULL) return -1; @@ -284,12 +286,14 @@ STDMETHODIMP_(BOOL) CDbxMdb::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) STDMETHODIMP_(MCONTACT) CDbxMdb::GetEventContact(MEVENT hDbEvent) { + if (hDbEvent == 0) return INVALID_CONTACT_ID; + mir_cslock lck(m_csDbAccess); txn_ptr txn(m_pMdbEnv, true); MDB_val key = { sizeof(MEVENT), &hDbEvent }, data; if (mdb_get(txn, m_dbEvents, &key, &data) != MDB_SUCCESS) - return 0; + return INVALID_CONTACT_ID; DBEvent *dbe = (DBEvent*)data.mv_data; return (dbe->dwSignature == DBEVENT_SIGNATURE) ? dbe->contactID : INVALID_CONTACT_ID; @@ -339,6 +343,8 @@ STDMETHODIMP_(MEVENT) CDbxMdb::FindLastEvent(MCONTACT contactID) STDMETHODIMP_(MEVENT) CDbxMdb::FindNextEvent(MCONTACT contactID, MEVENT hDbEvent) { + if (hDbEvent == 0) return m_evLast = 0; + MDB_val data; DWORD ts; @@ -370,6 +376,8 @@ STDMETHODIMP_(MEVENT) CDbxMdb::FindNextEvent(MCONTACT contactID, MEVENT hDbEvent STDMETHODIMP_(MEVENT) CDbxMdb::FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent) { + if (hDbEvent == 0) return m_evLast = 0; + MDB_val data; DWORD ts; -- cgit v1.2.3