mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-28 16:24:27 +02:00
Code enhancement: prevent from signed integer overflow
Ref:
94154b0f0e (commitcomment-66609009)
This commit is contained in:
parent
51b1c9377c
commit
2df765e189
@ -3494,7 +3494,7 @@ void FindReplaceDlg::enableProjectCheckmarks()
|
|||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
UINT s = GetMenuState (hMenu, idm [i], MF_BYCOMMAND);
|
UINT s = GetMenuState (hMenu, idm [i], MF_BYCOMMAND);
|
||||||
if (static_cast<int>(s) != -1)
|
if (s != ((UINT)-1))
|
||||||
{
|
{
|
||||||
if (s & MF_CHECKED)
|
if (s & MF_CHECKED)
|
||||||
{
|
{
|
||||||
|
@ -104,7 +104,7 @@ void ContextMenu::create(HWND hParent, const std::vector<MenuItemUnit> & menuIte
|
|||||||
if (mainMenuHandle)
|
if (mainMenuHandle)
|
||||||
{
|
{
|
||||||
UINT s = ::GetMenuState(mainMenuHandle, item._cmdID, MF_BYCOMMAND);
|
UINT s = ::GetMenuState(mainMenuHandle, item._cmdID, MF_BYCOMMAND);
|
||||||
if (static_cast<int>(s) != -1)
|
if (s != ((UINT)-1))
|
||||||
{
|
{
|
||||||
bool isEnabled = (s & (MF_DISABLED | MF_GRAYED)) == 0;
|
bool isEnabled = (s & (MF_DISABLED | MF_GRAYED)) == 0;
|
||||||
bool isChecked = (s & (MF_CHECKED)) != 0;
|
bool isChecked = (s & (MF_CHECKED)) != 0;
|
||||||
|
@ -899,7 +899,7 @@ void WindowsDlg::doClose()
|
|||||||
vector<int>::iterator kitr = key.begin();
|
vector<int>::iterator kitr = key.begin();
|
||||||
for (UINT i = 0; i < n; ++i, ++kitr)
|
for (UINT i = 0; i < n; ++i, ++kitr)
|
||||||
{
|
{
|
||||||
if (static_cast<int>(nmdlg.Items[i]) == -1)
|
if (nmdlg.Items[i] == ((UINT)-1))
|
||||||
{
|
{
|
||||||
int oldVal = _idxMap[*kitr];
|
int oldVal = _idxMap[*kitr];
|
||||||
_idxMap[*kitr] = -1;
|
_idxMap[*kitr] = -1;
|
||||||
@ -1115,7 +1115,7 @@ void WindowsMenu::initPopupMenu(HMENU hMenu, DocTabView *pTab)
|
|||||||
mii.wID = id;
|
mii.wID = id;
|
||||||
|
|
||||||
UINT state = GetMenuState(hMenu, id, MF_BYCOMMAND);
|
UINT state = GetMenuState(hMenu, id, MF_BYCOMMAND);
|
||||||
if (static_cast<int>(state) == -1)
|
if (state == ((UINT)-1))
|
||||||
InsertMenuItem(hMenu, IDM_WINDOW_WINDOWS, FALSE, &mii);
|
InsertMenuItem(hMenu, IDM_WINDOW_WINDOWS, FALSE, &mii);
|
||||||
else
|
else
|
||||||
SetMenuItemInfo(hMenu, id, FALSE, &mii);
|
SetMenuItemInfo(hMenu, id, FALSE, &mii);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user