Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/plugin/PluginClass.cpp

Issue 5163581322559488: Issue 1283 - wrong usage of memset, fix sizeof, make proper initializing (Closed)
Patch Set: Created Oct. 8, 2014, 2:49 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/plugin/NotificationMessage.cpp ('k') | src/plugin/PluginSettings.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/plugin/PluginClass.cpp
===================================================================
--- a/src/plugin/PluginClass.cpp
+++ b/src/plugin/PluginClass.cpp
@@ -14,7 +14,6 @@
#include "../shared/Utils.h"
#include "../shared/Dictionary.h"
#include <thread>
-#include <array>
#ifdef DEBUG_HIDE_EL
DWORD profileTime = 0;
@@ -416,17 +415,17 @@
HKEY pHkey;
HKEY pHkeySub;
RegOpenCurrentUser(KEY_QUERY_VALUE, &pHkey);
- DWORD truth = 1;
- DWORD truthSize = sizeof(truth);
+ DWORD trueth = 1;
+ DWORD truethSize = sizeof(DWORD);
RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\Main", &pHkeySub);
- LONG res = RegQueryValueEx(pHkeySub, L"StatusBarWeb", NULL, NULL, (BYTE*)&truth, &truthSize);
+ LONG res = RegQueryValueEx(pHkeySub, L"StatusBarWeb", NULL, NULL, (BYTE*)&trueth, &truethSize);
RegCloseKey(pHkey);
if (res != ERROR_SUCCESS)
{
res = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\MINIE", &pHkeySub);
if (res == ERROR_SUCCESS)
{
- LONG res = RegQueryValueEx(pHkeySub, L"ShowStatusBar", NULL, NULL, (BYTE*)&truth, &truthSize);
+ LONG res = RegQueryValueEx(pHkeySub, L"ShowStatusBar", NULL, NULL, (BYTE*)&trueth, &truethSize);
if (res == ERROR_SUCCESS)
{
RegCloseKey(pHkey);
@@ -434,7 +433,7 @@
}
}
DEBUG_GENERAL("IsStatusBarEnabled end");
- return truth == 1;
+ return trueth == 1;
}
void CPluginClass::ShowStatusBar()
@@ -479,12 +478,12 @@
MB_YESNO);
if (res == IDYES)
{
- DWORD truth = 1;
+ DWORD trueth = 1;
regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\MINIE", &pHkeySub);
- regRes = RegSetValueEx(pHkeySub, L"ShowStatusBar", 0, REG_DWORD, (BYTE*)&truth, sizeof(truth));
+ regRes = RegSetValueEx(pHkeySub, L"ShowStatusBar", 0, REG_DWORD, (BYTE*)&trueth, sizeof(DWORD));
regRes = RegCloseKey(pHkeySub);
regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\Main", &pHkeySub);
- regRes = RegSetValueEx(pHkeySub, L"StatusBarWeb", 0, REG_DWORD, (BYTE*)&truth, sizeof(truth));
+ regRes = RegSetValueEx(pHkeySub, L"StatusBarWeb", 0, REG_DWORD, (BYTE*)&trueth, sizeof(DWORD));
regRes = RegCloseKey(pHkeySub);
hr = browser->put_StatusBar(TRUE);
if (FAILED(hr))
@@ -806,7 +805,7 @@
{
WNDCLASSEX wcex;
- wcex.cbSize = sizeof(wcex);
+ wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = 0;
wcex.lpfnWndProc = (WNDPROC)PaneWindowProc;
wcex.cbClsExtra = 0;
@@ -882,7 +881,7 @@
CPluginClient* client = CPluginClient::GetInstance();
- std::array<wchar_t, MAX_PATH> className;
+ wchar_t szClassName[MAX_PATH];
// Get browser window and url
HWND hBrowserWnd = GetBrowserHWND();
if (!hBrowserWnd)
@@ -900,15 +899,14 @@
HWND uniqueNewTab = NULL;
while (hTabWnd)
{
- className[0] = L'\0';
- // GetClassNameW returns the number of characters without '\0'
- int classNameLength = GetClassNameW(hTabWnd, className.data(), className.size());
+ memset(szClassName, 0, MAX_PATH);
+ GetClassName(hTabWnd, szClassName, MAX_PATH);
- if (classNameLength && (wcscmp(className.data(), L"TabWindowClass") == 0 || wcscmp(className.data(), L"Frame Tab") == 0))
+ if (wcscmp(szClassName, L"TabWindowClass") == 0 || wcscmp(szClassName,L"Frame Tab") == 0)
{
// IE8 support
HWND hTabWnd2 = hTabWnd;
- if (wcscmp(className.data(), L"Frame Tab") == 0)
+ if (wcscmp(szClassName,L"Frame Tab") == 0)
{
hTabWnd2 = ::FindWindowEx(hTabWnd2, NULL, L"TabWindowClass", NULL);
}
@@ -955,10 +953,10 @@
HWND hWnd = ::GetWindow(hBrowserWnd, GW_CHILD);
while (hWnd)
{
- className[0] = L'\0';
- int classNameLength = GetClassNameW(hWnd, className.data(), className.size());
+ memset(szClassName, 0, MAX_PATH);
+ ::GetClassName(hWnd, szClassName, MAX_PATH);
- if (classNameLength && wcscmp(className.data(), L"msctls_statusbar32") == 0)
+ if (wcscmp(szClassName,L"msctls_statusbar32") == 0)
{
hWndStatusBar = hWnd;
break;
@@ -1283,11 +1281,13 @@
Dictionary* dictionary = Dictionary::GetInstance();
- MENUITEMINFOW fmii = {};
- fmii.cbSize = sizeof(fmii);
+ MENUITEMINFOW fmii;
+ memset(&fmii, 0, sizeof(MENUITEMINFO));
+ fmii.cbSize = sizeof(MENUITEMINFO);
- MENUITEMINFOW miiSep = {};
- miiSep.cbSize = sizeof(miiSep);
+ MENUITEMINFOW miiSep;
+ memset(&miiSep, 0, sizeof(MENUITEMINFO));
+ miiSep.cbSize = sizeof(MENUITEMINFO);
miiSep.fMask = MIIM_TYPE | MIIM_FTYPE;
miiSep.fType = MFT_SEPARATOR;
@@ -1382,7 +1382,8 @@
if (nButton > 0)
{
- TBBUTTON pTBBtn = {};
+ TBBUTTON pTBBtn;
+ memset(&pTBBtn, 0, sizeof(TBBUTTON));
if (SendMessage(hWndToolBar, TB_GETBUTTON, nButton, (LPARAM)&pTBBtn))
{
@@ -1804,7 +1805,7 @@
HWND CPluginClass::GetTabHWND() const
{
- std::array<wchar_t, MAX_PATH> className;
+ wchar_t szClassName[MAX_PATH];
// Get browser window and url
HWND hBrowserWnd = GetBrowserHWND();
if (!hBrowserWnd)
@@ -1820,14 +1821,14 @@
HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD);
while (hTabWnd)
{
- className[0] = L'\0';
- int classNameLength = GetClassNameW(hTabWnd, className.data(), className.size());
+ memset(szClassName, 0, MAX_PATH);
+ GetClassName(hTabWnd, szClassName, MAX_PATH);
- if (classNameLength && (wcscmp(className.data(), L"TabWindowClass") == 0 || wcscmp(className.data(), L"Frame Tab") == 0))
+ if (wcscmp(szClassName, L"TabWindowClass") == 0 || wcscmp(szClassName, L"Frame Tab") == 0)
{
// IE8 support
HWND hTabWnd2 = hTabWnd;
- if (wcscmp(className.data(), L"Frame Tab") == 0)
+ if (wcscmp(szClassName, L"Frame Tab") == 0)
{
hTabWnd2 = ::FindWindowEx(hTabWnd2, NULL, L"TabWindowClass", NULL);
}
« no previous file with comments | « src/plugin/NotificationMessage.cpp ('k') | src/plugin/PluginSettings.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld