From 3f09ebc976eff21027248e5fb3b9a23ba7315645 Mon Sep 17 00:00:00 2001 From: A-R-C-A Date: Thu, 30 Jun 2016 01:42:53 +0000 Subject: [PATCH] Fixed crash issue due to unsigned variable Close #2035 --- PowerEditor/src/MISC/RegExt/regExtDlg.cpp | 2 +- PowerEditor/src/Notepad_plus.cpp | 2 +- PowerEditor/src/NppIO.cpp | 8 ++++---- PowerEditor/src/NppNotification.cpp | 2 +- .../src/WinControls/DockingWnd/DockingManager.cpp | 2 +- PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp | 2 +- PowerEditor/src/WinControls/shortcut/shortcut.cpp | 2 +- PowerEditor/src/uchardet/nsEscCharsetProber.cpp | 10 +++------- 8 files changed, 13 insertions(+), 17 deletions(-) diff --git a/PowerEditor/src/MISC/RegExt/regExtDlg.cpp b/PowerEditor/src/MISC/RegExt/regExtDlg.cpp index 848d8961..7cd0d66f 100644 --- a/PowerEditor/src/MISC/RegExt/regExtDlg.cpp +++ b/PowerEditor/src/MISC/RegExt/regExtDlg.cpp @@ -222,7 +222,7 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar _isCustomize = false; } - auto count = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_GETCOUNT, 0, 0); + LRESULT count = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_GETCOUNT, 0, 0); for (count -= 1 ; count >= 0 ; count--) ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_DELETESTRING, count, 0); diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index f569a732..4c615840 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2533,7 +2533,7 @@ void Notepad_plus::maintainIndentation(TCHAR ch) auto startPos = _pEditView->execute(SCI_POSITIONFROMLINE, curLine); auto endPos = _pEditView->execute(SCI_GETCURRENTPOS); - for (auto i = endPos - 2; i > 0 && i > startPos; --i) + for (long long i = endPos - 2; i > 0 && i > startPos; --i) { UCHAR aChar = (UCHAR)_pEditView->execute(SCI_GETCHARAT, i); if (aChar != ' ' && aChar != '\t') diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 8feb0362..957a1400 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -966,14 +966,14 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode) //first close all docs in non-current view, which gets closed automatically //Set active tab to the last one closed. activateBuffer(_pNonDocTab->getBufferByIndex(0), otherView()); - for (size_t i = _pNonDocTab->nbItem() - 1; i >= 0; i--) //close all from right to left + for (int32_t i = static_cast(_pNonDocTab->nbItem()) - 1; i >= 0; i--) //close all from right to left { doClose(_pNonDocTab->getBufferByIndex(i), otherView(), doDeleteBackup); } } activateBuffer(_pDocTab->getBufferByIndex(0), currentView()); - for (int i = static_cast(_pDocTab->nbItem()) - 1; i >= 0; i--) + for (int32_t i = static_cast(_pDocTab->nbItem()) - 1; i >= 0; i--) { //close all from right to left doClose(_pDocTab->getBufferByIndex(i), currentView(), doDeleteBackup); } @@ -1123,14 +1123,14 @@ bool Notepad_plus::fileCloseAllButCurrent() //Set active tab to the last one closed. activateBuffer(_pNonDocTab->getBufferByIndex(0), otherView()); - for (int i = int(_pNonDocTab->nbItem()) - 1; i >= 0; i--) //close all from right to left + for (int32_t i = static_cast(_pNonDocTab->nbItem()) - 1; i >= 0; i--) //close all from right to left { doClose(_pNonDocTab->getBufferByIndex(i), otherView(), isSnapshotMode); } } activateBuffer(_pDocTab->getBufferByIndex(0), currentView()); - for (int i = int(_pDocTab->nbItem()) - 1; i >= 0; i--) //close all from right to left + for (int32_t i = static_cast(_pDocTab->nbItem()) - 1; i >= 0; i--) //close all from right to left { if (i == active) //dont close active index { diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 20db6088..cbb2b39a 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -582,7 +582,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) { // If the delimiters are the same (e.g. they are both a quotation mark), choose the ones // which are closest to the clicked position. - for (int i = static_cast(position_of_click); i >= 0; --i) + for (int32_t i = static_cast(position_of_click); i >= 0; --i) { if (bufstring.at(i) == nppGUI._leftmostDelimiter) { diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp index df0187ad..2cdf3c35 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp @@ -262,7 +262,7 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l } // destroy containers - for (size_t i = _vContainer.size(); i > 0; i--) + for (int32_t i = static_cast(_vContainer.size()); i > 0; i--) { _vContainer[i-1]->destroy(); delete _vContainer[i-1]; diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp index d628e66e..af682960 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp @@ -784,7 +784,7 @@ void WindowsMenu::init(HINSTANCE hInst, HMENU hMainMenu, const TCHAR *translatio ::ModifyMenu(_hMenu, IDM_WINDOW_WINDOWS, MF_BYCOMMAND, IDM_WINDOW_WINDOWS, windowStr.c_str()); } - UINT pos = 0; + int32_t pos = 0; for(pos = GetMenuItemCount(hMainMenu) - 1; pos > 0; --pos) { if ((GetMenuState(hMainMenu, pos, MF_BYPOSITION) & MF_POPUP) != MF_POPUP) diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index 6871329f..e4babe9f 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -693,7 +693,7 @@ void ScintillaAccelerator::updateKeys() for(int i = 0; i < _nrScintillas; ++i) { ::SendMessage(_vScintillas[i], SCI_CLEARALLCMDKEYS, 0, 0); - for(size_t j = mapSize - 1; j >= 0; j--) //reverse order, top of the list has highest priority + for(int32_t j = static_cast(mapSize) - 1; j >= 0; j--) //reverse order, top of the list has highest priority { ScintillaKeyMap skm = map[j]; if (skm.isEnabled()) diff --git a/PowerEditor/src/uchardet/nsEscCharsetProber.cpp b/PowerEditor/src/uchardet/nsEscCharsetProber.cpp index 464c7534..128f0a22 100644 --- a/PowerEditor/src/uchardet/nsEscCharsetProber.cpp +++ b/PowerEditor/src/uchardet/nsEscCharsetProber.cpp @@ -75,17 +75,13 @@ void nsEscCharSetProber::Reset(void) nsProbingState nsEscCharSetProber::HandleData(const char* aBuf, PRUint32 aLen) { - nsSMState codingState; - PRInt32 j; - PRUint32 i; - - for ( i = 0; i < aLen && mState == eDetecting; i++) + for (PRUint32 i = 0; i < aLen && mState == eDetecting; i++) { - for (j = mActiveSM-1; j>= 0; j--) + for (PRInt32 j = mActiveSM-1; j>= 0; j--) { if (mCodingSM[j]) { - codingState = mCodingSM[j]->NextState(aBuf[i]); + nsSMState codingState = mCodingSM[j]->NextState(aBuf[i]); if (codingState == eItsMe) { mState = eFoundIt;