Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int idToIndex(const int id) const
- {
- for(int i = 0; i < NR_BUTTONS; i++) {
- if(m_TbButtons[i].idCommand == id )
- return(i);
- }
- return(-1);
- }
- TBBUTTON CMenuBar::m_TbButtons[8] = {0};
- void CMenuBar::invoke(const int id)
- {
- const int index = idToIndex(id);
- ....
- if(index == 3 && hContact != 0) {
- ....
- } else if(index == 0) {
- ....
- } else
- hMenu = reinterpret_cast<HMENU>(m_TbButtons[index].dwData);
- ....
- }
- This suspicious code was found in Miranda IM project by PVS-Studio static code analyzer.
- Warning message is:
- V557 Array underrun is possible. The value of 'index' index could reach -1. controls.cpp 491
- PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment