summaryrefslogtreecommitdiff
path: root/plugins/Dbx_kv
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Dbx_kv')
-rw-r--r--plugins/Dbx_kv/src/dbevents.cpp14
-rw-r--r--plugins/Dbx_kv/src/dbintf.cpp2
2 files changed, 13 insertions, 3 deletions
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;