]> git.saurik.com Git - wxWidgets.git/blobdiff - src/html/htmltag.cpp
fixed a rare crash due to malformed HTML
[wxWidgets.git] / src / html / htmltag.cpp
index f5e93ffa033914e5fe09e94cf0d7f6f554d29b3f..014945054366c5fb6229d6dec1e34709b1ca8df5 100644 (file)
@@ -194,6 +194,16 @@ void wxHtmlTagsCache::QueryTag(int at, int* end1, int* end2)
         int delta = (at < m_Cache[m_CachePos].Key) ? -1 : 1;
         do
         {
+            if ( m_CachePos < 0 || m_CachePos == m_CacheSize )
+            {
+                // something is very wrong with HTML, give up by returning an
+                // impossibly large value which is going to be ignored by the
+                // caller
+                *end1 =
+                *end2 = INT_MAX;
+                return;
+            }
+
             m_CachePos += delta;
         }
         while (m_Cache[m_CachePos].Key != at);