X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4365da58c8f11f5c0bee18cc03ff81664c639299..d94974609888885e0b75d0e01d901b03a6213979:/src/common/dynarray.cpp

diff --git a/src/common/dynarray.cpp b/src/common/dynarray.cpp
index 012c6077a3..2b185f156f 100644
--- a/src/common/dynarray.cpp
+++ b/src/common/dynarray.cpp
@@ -283,10 +283,10 @@ int name::Index(T lItem, CMPFUNC fnCompare) const                           \
 {                                                                           \
     size_t n = IndexForInsert(lItem, fnCompare);                            \
                                                                             \
-    return n < m_nCount &&                                                  \
+    return (n >= m_nCount ||                                                \
            (*fnCompare)((const void *)(long)lItem,                          \
-                        ((const void *)(long)m_pItems[n])) ? (int)n         \
-                                                           : wxNOT_FOUND;   \
+                        ((const void *)(long)m_pItems[n]))) ? wxNOT_FOUND   \
+                                                            : (int)n;       \
 }                                                                           \
                                                                             \
 /* add item at the end */                                                   \