From 5269daf337ff67b0a804e7c63909a800b335a8db Mon Sep 17 00:00:00 2001
From: George Hazan <george.hazan@gmail.com>
Date: Sat, 3 Aug 2013 12:37:31 +0000
Subject: various leak fixes

git-svn-id: http://svn.miranda-ng.org/main/trunk@5563 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
---
 plugins/TabSRMM/src/tabctrl.cpp |  8 +++-----
 plugins/TabSRMM/src/themes.cpp  |  2 ++
 src/mir_core/db.cpp             | 13 ++++++++++---
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/plugins/TabSRMM/src/tabctrl.cpp b/plugins/TabSRMM/src/tabctrl.cpp
index 4d8bd97029..b82f1c9b0e 100644
--- a/plugins/TabSRMM/src/tabctrl.cpp
+++ b/plugins/TabSRMM/src/tabctrl.cpp
@@ -1412,12 +1412,10 @@ void TSAPI FreeTabConfig()
 	if (PluginConfig.tabConfig.m_hMenuFont)
 		DeleteObject(PluginConfig.tabConfig.m_hMenuFont);
 
-	for (int i=0; i < 4; i++) {
-		if (PluginConfig.tabConfig.m_brushes[i]) {
+	for (int i=0; i < SIZEOF(PluginConfig.tabConfig.m_brushes); i++)
+		if (PluginConfig.tabConfig.m_brushes[i])
 			DeleteObject(PluginConfig.tabConfig.m_brushes[i]);
-			PluginConfig.tabConfig.m_brushes[i] = 0;
-		}
-	}
+
 	ZeroMemory(&PluginConfig.tabConfig, sizeof(myTabCtrl));
 }
 
diff --git a/plugins/TabSRMM/src/themes.cpp b/plugins/TabSRMM/src/themes.cpp
index ad31a69a00..4812dedb61 100644
--- a/plugins/TabSRMM/src/themes.cpp
+++ b/plugins/TabSRMM/src/themes.cpp
@@ -1167,6 +1167,8 @@ void CSkin::Unload()
 		::DeleteObject(m_ContainerColorKeyBrush);
 	if (m_MenuBGBrush)
 		::DeleteObject(m_MenuBGBrush);
+	if (m_BrushBack)
+		::DeleteObject(m_BrushBack);
 
 	m_ContainerColorKeyBrush = m_MenuBGBrush = 0;
 
diff --git a/src/mir_core/db.cpp b/src/mir_core/db.cpp
index 6b066e1af8..7d6491c1e0 100644
--- a/src/mir_core/db.cpp
+++ b/src/mir_core/db.cpp
@@ -36,12 +36,14 @@ MIR_CORE_DLL(int) db_get_b(HANDLE hContact, const char *szModule, const char *sz
 		cgs.szModule = szModule;
 		cgs.szSetting = szSetting;
 		cgs.pValue = &dbv;
-		if ( !currDb->GetContactSetting(hContact, &cgs))
+		if ( !currDb->GetContactSetting(hContact, &cgs)) {
 			switch(dbv.type) {
 				case DBVT_BYTE:	return dbv.bVal;
 				case DBVT_WORD:   return BYTE(dbv.wVal);
 				case DBVT_DWORD:	return BYTE(dbv.dVal);
 			}
+			currDb->FreeVariant(&dbv);
+		}
 	}
 	return errorValue;
 }
@@ -54,12 +56,14 @@ MIR_CORE_DLL(int) db_get_w(HANDLE hContact, const char *szModule, const char *sz
 		cgs.szModule = szModule;
 		cgs.szSetting = szSetting;
 		cgs.pValue = &dbv;
-		if ( !currDb->GetContactSetting(hContact, &cgs))
+		if ( !currDb->GetContactSetting(hContact, &cgs)) {
 			switch(dbv.type) {
 				case DBVT_BYTE:	return dbv.bVal;
 				case DBVT_WORD:   return dbv.wVal;
 				case DBVT_DWORD:	return WORD(dbv.dVal);
 			}
+			currDb->FreeVariant(&dbv);
+		}
 	}
 	return errorValue;
 }
@@ -72,12 +76,15 @@ MIR_CORE_DLL(DWORD) db_get_dw(HANDLE hContact, const char *szModule, const char
 		cgs.szModule = szModule;
 		cgs.szSetting = szSetting;
 		cgs.pValue = &dbv;
-		if ( !currDb->GetContactSetting(hContact, &cgs))
+		if ( !currDb->GetContactSetting(hContact, &cgs)) {
 			switch(dbv.type) {
 				case DBVT_BYTE:	return dbv.bVal;
 				case DBVT_WORD:   return dbv.wVal;
 				case DBVT_DWORD:	return dbv.dVal;
+				default: currDb->FreeVariant(&dbv);
 			}
+			currDb->FreeVariant(&dbv);
+		}
 	}
 
 	return errorValue;
-- 
cgit v1.2.3