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_kv/src/dbevents.cpp | 14 ++++++++++++-- plugins/Dbx_kv/src/dbintf.cpp | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'plugins/Dbx_kv') diff --git a/plugins/Dbx_kv/src/dbevents.cpp b/plugins/Dbx_kv/src/dbevents.cpp index 466a732189..72a0f239e7 100644 --- a/plugins/Dbx_kv/src/dbevents.cpp +++ b/plugins/Dbx_kv/src/dbevents.cpp @@ -115,6 +115,8 @@ STDMETHODIMP_(MEVENT) CDbxKV::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) STDMETHODIMP_(BOOL) CDbxKV::DeleteEvent(MCONTACT contactID, MEVENT hDbEvent) { + if (hDbEvent == 0) return INVALID_CONTACT_ID; + DBCachedContact *cc = m_cache->GetCachedContact(contactID); if (cc == NULL || cc->dbc.dwEventCount == 0) return 1; @@ -163,7 +165,7 @@ STDMETHODIMP_(LONG) CDbxKV::GetBlobSize(MEVENT hDbEvent) STDMETHODIMP_(BOOL) CDbxKV::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei) { - if (dbei == NULL || dbei->cbSize != sizeof(DBEVENTINFO)) return 1; + if (hDbEvent == 0 || dbei == NULL || dbei->cbSize != sizeof(DBEVENTINFO)) return 1; if (dbei->cbBlob > 0 && dbei->pBlob == NULL) { dbei->cbBlob = 0; return 1; @@ -227,6 +229,8 @@ void CDbxKV::FindNextUnread(DBCachedContact *cc, DBEventSortingKey &key2) STDMETHODIMP_(BOOL) CDbxKV::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) { + if (hDbEvent == 0) return -1; + DBCachedContact *cc = m_cache->GetCachedContact(contactID); if (cc == NULL) return -1; @@ -259,10 +263,12 @@ STDMETHODIMP_(BOOL) CDbxKV::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) STDMETHODIMP_(MCONTACT) CDbxKV::GetEventContact(MEVENT hDbEvent) { + if (hDbEvent == 0) return INVALID_CONTACT_ID; + ham_record_t rec = { 0 }; ham_key_t key = { sizeof(MEVENT), &hDbEvent }; if (ham_db_find(m_dbEvents, NULL, &key, &rec, HAM_FIND_EXACT_MATCH) != HAM_SUCCESS) - return 0; + return INVALID_CONTACT_ID; DBEvent *dbe = (DBEvent*)rec.data; return (dbe->dwSignature == DBEVENT_SIGNATURE) ? dbe->contactID : INVALID_CONTACT_ID; @@ -304,6 +310,8 @@ STDMETHODIMP_(MEVENT) CDbxKV::FindLastEvent(MCONTACT contactID) STDMETHODIMP_(MEVENT) CDbxKV::FindNextEvent(MCONTACT contactID, MEVENT hDbEvent) { + if (hDbEvent == 0) return m_evLast = 0; + DWORD ts; ham_record_t rec = { 0 }; @@ -327,6 +335,8 @@ STDMETHODIMP_(MEVENT) CDbxKV::FindNextEvent(MCONTACT contactID, MEVENT hDbEvent) STDMETHODIMP_(MEVENT) CDbxKV::FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent) { + if (hDbEvent == 0) return m_evLast = 0; + DWORD ts; ham_record_t rec = { 0 }; diff --git a/plugins/Dbx_kv/src/dbintf.cpp b/plugins/Dbx_kv/src/dbintf.cpp index 0b323a125a..aa4c7ac775 100644 --- a/plugins/Dbx_kv/src/dbintf.cpp +++ b/plugins/Dbx_kv/src/dbintf.cpp @@ -177,7 +177,7 @@ int CDbxKV::Load(bool bSkipInit) int CDbxKV::Create(void) { - int flags = HAM_ENABLE_FSYNC | HAM_DISABLE_RECOVERY; + int flags = HAM_ENABLE_FSYNC | HAM_ENABLE_RECOVERY | HAM_ENABLE_FSYNC; if (ham_env_create(&m_pMdbEnv, _T2A(m_tszProfileName), flags, 0664, NULL) != HAM_SUCCESS) return EGROKPRF_CANTREAD; -- cgit v1.2.3