diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2016-01-21 13:58:44 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2016-01-21 13:58:44 +0000 |
commit | f766a15d16ee4a719fdf7ce273f87a333d90a40b (patch) | |
tree | 47803e5530bc8a4388b86b6d2eebd9fc97bb27f5 /plugins/IEView/src/external_funcs.cpp | |
parent | db58ffd66b837aa184ee8d934811b78f9ff8040b (diff) |
IEView: memleaks fix, warnings fix
git-svn-id: http://svn.miranda-ng.org/main/trunk@16136 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/IEView/src/external_funcs.cpp')
-rw-r--r-- | plugins/IEView/src/external_funcs.cpp | 67 |
1 files changed, 39 insertions, 28 deletions
diff --git a/plugins/IEView/src/external_funcs.cpp b/plugins/IEView/src/external_funcs.cpp index 3f38f4d3f1..599734805b 100644 --- a/plugins/IEView/src/external_funcs.cpp +++ b/plugins/IEView/src/external_funcs.cpp @@ -5,40 +5,48 @@ namespace External HRESULT db_get(DISPPARAMS *pDispParams, VARIANT *pVarResult)
{
if (pDispParams->cArgs < 3)
- return TYPE_E_OUTOFBOUNDS;
-
- if (!pDispParams || !pVarResult)
- return S_OK;
+ return E_INVALIDARG;
- MCONTACT hContact = pDispParams->rgvarg[2].vt == VT_INT ? pDispParams->rgvarg[2].intVal : NULL;
- BSTR szModule = pDispParams->rgvarg[1].vt == VT_BSTR ? pDispParams->rgvarg[1].bstrVal : NULL;
- BSTR szSetting = pDispParams->rgvarg[0].vt == VT_BSTR ? pDispParams->rgvarg[0].bstrVal : NULL;
+ MCONTACT hContact = pDispParams->rgvarg[2].intVal;
+ BSTR szModule = pDispParams->rgvarg[1].bstrVal;
+ BSTR szSetting = pDispParams->rgvarg[0].bstrVal;
DBVARIANT dbv = { 0 };
- db_get(hContact, _T2A((TCHAR*)szModule), _T2A((TCHAR*)szSetting), &dbv);
- switch (dbv.type)
+ if (db_get(hContact, _T2A((TCHAR*)szModule), _T2A((TCHAR*)szSetting), &dbv))
+ return E_FAIL;
+
+ if (pVarResult != nullptr)
{
- case DBVT_BYTE:
- pVarResult->bVal = dbv.bVal;
- pVarResult->vt = VT_BOOL;
- break;
- case DBVT_WCHAR:
- pVarResult->vt = VT_BSTR;
- pVarResult->bstrVal = ::SysAllocString(dbv.pwszVal);
- break;
- case DBVT_UTF8:
- pVarResult->vt = VT_BSTR;
- pVarResult->bstrVal = ::SysAllocString(ptrW(mir_utf8decodeW(dbv.pszVal)));
- break;
- case DBVT_ASCIIZ:
- pVarResult->vt = VT_BSTR;
- pVarResult->bstrVal = ::SysAllocString(_A2T(dbv.pszVal));
- break;
- case DBVT_DWORD:
- pVarResult->vt = VT_INT;
- pVarResult->intVal = dbv.dVal;
+ switch (dbv.type)
+ {
+ case DBVT_BYTE:
+ pVarResult->bVal = dbv.bVal;
+ pVarResult->vt = VT_BOOL;
+ break;
+ case DBVT_WCHAR:
+ pVarResult->vt = VT_BSTR;
+ pVarResult->bstrVal = ::SysAllocString(dbv.pwszVal);
+ break;
+ case DBVT_UTF8:
+ pVarResult->vt = VT_BSTR;
+ pVarResult->bstrVal = ::SysAllocString(ptrW(mir_utf8decodeW(dbv.pszVal)));
+ break;
+ case DBVT_ASCIIZ:
+ pVarResult->vt = VT_BSTR;
+ pVarResult->bstrVal = ::SysAllocString(_A2T(dbv.pszVal));
+ break;
+ case DBVT_DWORD:
+ pVarResult->vt = VT_INT;
+ pVarResult->intVal = dbv.dVal;
+ break;
+ case DBVT_WORD:
+ pVarResult->vt = VT_I2;
+ pVarResult->iVal = dbv.dVal;
+ break;
+ }
}
+ db_free(&dbv);
return S_OK;
}
@@ -72,6 +80,9 @@ namespace External case VT_BOOL:
dbv.type = DBVT_BYTE;
dbv.bVal = pVal.boolVal;
+ break;
+ default:
+ return E_INVALIDARG;
}
INT_PTR res = ::db_set(hContact, _T2A((TCHAR*)szModule), _T2A((TCHAR*)szSetting), &dbv);
|