From 089e7f228a5d22219ddb059674809c47769d5e53 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Fri, 2 Oct 2015 16:08:16 +0000 Subject: Toaster: coverity fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@15488 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Toaster/src/images.h | 4 ++-- plugins/Toaster/src/main.cpp | 16 +++++++++++----- plugins/Toaster/src/services.cpp | 2 +- plugins/Toaster/src/structs.h | 10 +++++++--- 4 files changed, 21 insertions(+), 11 deletions(-) (limited to 'plugins/Toaster') diff --git a/plugins/Toaster/src/images.h b/plugins/Toaster/src/images.h index 320a368769..01b05720d1 100644 --- a/plugins/Toaster/src/images.h +++ b/plugins/Toaster/src/images.h @@ -6,7 +6,7 @@ class ToasterImage ptrT tszId; public: - __inline explicit ToasterImage(HICON hIcon) : tszId(CMString(FORMAT, _T("%p"), hIcon).Detach()) + __inline explicit ToasterImage(HICON hIcon) : _hBitmap(NULL), tszId(CMString(FORMAT, _T("%p"), hIcon).Detach()) { ICONINFO icon = { 0 }; if (GetIconInfo(hIcon, &icon)) @@ -20,7 +20,7 @@ public: { } - __inline explicit ToasterImage(const char *szProto) : tszId(mir_a2t(szProto)) + __inline explicit ToasterImage(const char *szProto) : _hBitmap(NULL), tszId(mir_a2t(szProto)) { ICONINFO icon = { 0 }; if (GetIconInfo(Skin_LoadProtoIcon(szProto, ID_STATUS_ONLINE, 1), &icon)) diff --git a/plugins/Toaster/src/main.cpp b/plugins/Toaster/src/main.cpp index e7006bb52d..e489c11e61 100644 --- a/plugins/Toaster/src/main.cpp +++ b/plugins/Toaster/src/main.cpp @@ -44,12 +44,18 @@ extern "C" int __declspec(dllexport) Load(void) InitServices(); - GetEnvironmentVariableW(L"TEMP", wszTempDir, MAX_PATH); - wcscat_s(wszTempDir, L"\\Miranda.Toaster"); + if (GetEnvironmentVariableW(L"TEMP", wszTempDir, MAX_PATH) != 0) + { + wcscat_s(wszTempDir, L"\\Miranda.Toaster"); - DWORD dwAttributes = GetFileAttributes(wszTempDir); - if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) - CreateDirectoryTreeT(wszTempDir); + DWORD dwAttributes = GetFileAttributes(wszTempDir); + if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) + CreateDirectoryTreeT(wszTempDir); + } + else + { + MessageBox(NULL, TranslateT("Failed create temporary directory"), _T(MODULE), MB_OK | MB_ICONERROR); + } return 0; } diff --git a/plugins/Toaster/src/services.cpp b/plugins/Toaster/src/services.cpp index 8cc9beaaae..973625c35f 100644 --- a/plugins/Toaster/src/services.cpp +++ b/plugins/Toaster/src/services.cpp @@ -168,7 +168,7 @@ static INT_PTR CreateClassPopup(WPARAM, LPARAM lParam) } else { - td = new ToastData(ppc->hContact, mir_utf8decodeT(ppc->pszTitle), mir_utf8decodeT(ppc->pszText), it->second->hIcon); + td = new ToastData(ppc->hContact, ptrT(mir_utf8decodeT(ppc->pszTitle)), ptrT(mir_utf8decodeT(ppc->pszText)), it->second->hIcon); } td->vPopupData = ppc->PluginData; diff --git a/plugins/Toaster/src/structs.h b/plugins/Toaster/src/structs.h index 0aa4f59ae8..ad8835487a 100644 --- a/plugins/Toaster/src/structs.h +++ b/plugins/Toaster/src/structs.h @@ -20,14 +20,18 @@ struct ToastData : public MZeroedObject tszTitle(mir_tstrdup(_tszTitle)), tszText(mir_tstrdup(_tszText)), hIcon(_hIcon), - iType(_hIcon ? 2 : 0) + iType(_hIcon ? 2 : 0) , + pPopupProc(NULL), + vPopupData(NULL) {} ToastData(MCONTACT _hContact, const TCHAR *_tszTitle, const TCHAR *_tszText, HBITMAP bmp = NULL) : hContact(_hContact), tszTitle(mir_tstrdup(_tszTitle)), tszText(mir_tstrdup(_tszText)), hBitmap(bmp), - iType(bmp ? 1 : 0) + iType(bmp ? 1 : 0), + pPopupProc(NULL), + vPopupData(NULL) {} ~ToastData() { @@ -43,7 +47,7 @@ struct ClassData : public MZeroedObject WNDPROC pPopupProc; - ClassData(int f, HICON h = NULL) : iFlags(f), hIcon(h) + ClassData(int f, HICON h = NULL) : iFlags(f), hIcon(h), pPopupProc(NULL) { } }; -- cgit v1.2.3