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++)
|
||||
{
|
||||
UINT s = GetMenuState (hMenu, idm [i], MF_BYCOMMAND);
|
||||
if (static_cast<int>(s) != -1)
|
||||
if (s != ((UINT)-1))
|
||||
{
|
||||
if (s & MF_CHECKED)
|
||||
{
|
||||
|
|
|
@ -104,7 +104,7 @@ void ContextMenu::create(HWND hParent, const std::vector<MenuItemUnit> & menuIte
|
|||
if (mainMenuHandle)
|
||||
{
|
||||
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 isChecked = (s & (MF_CHECKED)) != 0;
|
||||
|
|
|
@ -897,9 +897,9 @@ void WindowsDlg::doClose()
|
|||
{
|
||||
// Trying to retain sort order. fairly sure there is a much better algorithm for this
|
||||
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];
|
||||
_idxMap[*kitr] = -1;
|
||||
|
@ -1115,7 +1115,7 @@ void WindowsMenu::initPopupMenu(HMENU hMenu, DocTabView *pTab)
|
|||
mii.wID = id;
|
||||
|
||||
UINT state = GetMenuState(hMenu, id, MF_BYCOMMAND);
|
||||
if (static_cast<int>(state) == -1)
|
||||
if (state == ((UINT)-1))
|
||||
InsertMenuItem(hMenu, IDM_WINDOW_WINDOWS, FALSE, &mii);
|
||||
else
|
||||
SetMenuItemInfo(hMenu, id, FALSE, &mii);
|
||||
|
|
Loading…
Reference in New Issue