Article ID: 173244
Article Last Modified on 11/21/2006
APPLIES TO
- Microsoft Foundation Class Library 4.2, when used with:
- Microsoft Visual C++ 2.0 Professional Edition
- Microsoft Visual C++ 2.1
- Microsoft Visual C++ 2.2
- Microsoft Visual C++ 4.0 Standard Edition
- Microsoft Visual C++ 4.1 Subscription
- Microsoft Visual C++ 4.2 Enterprise Edition
- Microsoft Visual C++ 4.2 Professional Edition
- Microsoft Visual C++ 5.0 Enterprise Edition
- Microsoft Visual C++ 5.0 Professional Edition
This article was previously published under Q173244
SYMPTOMS
If a value less than 0 is passed to the FindIndex function, the function will ASSERT in debug mode and enter an infinite loop in release mode.
CAUSE
The problem is that an ASSERT statement is used to test for a negative value in the FindIndex function instead of an if...then statement that would return NULL if the value is negative.
RESOLUTION
Check the value that is passed to FindIndex to make sure that it is not negative before calling the FindIndex function.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was corrected in Visual C++ version 6.0.
MORE INFORMATION
The documentation for the FindIndex function in the CList, CStringList, CPtrList, and CObList classes states that the return value is NULL if nIndex is negative or too large.
In release mode, the program may also generate the following application error:
REFERENCES
See AFXTEMPL.H for CList, LIST_S.cpp for CStringList, LIST_P.cpp for CPtrList, and LIST_O.cpp for CObList implementation details. The header file can be found in the in the ...\VC\mfc\include directory and the source files can be found in the ...\VC\mfc\src directory.
Keywords: kbbug kbfix kbnoupdate kbvc600fix KB173244