[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/khtml/misc
From:       Andreas Kling <kling () impul ! se>
Date:       2009-06-18 14:06:11
Message-ID: 1245333971.757440.15841.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 983596 by kling:

Fixed some OOB reads (one char past end of string) in findWordBoundary()


 M  +6 -6      helper.cpp  


--- trunk/KDE/kdelibs/khtml/misc/helper.cpp #983595:983596
@@ -49,29 +49,29 @@
 {
     if (chars[position].isSpace()) {
         int pos = position;
-        while (chars[pos].isSpace() && pos >= 0)
+        while (pos >= 0 && chars[pos].isSpace())
             pos--;
         *start = pos+1;
         pos = position;
-        while (chars[pos].isSpace() && pos < (int)len)
+        while (pos < (int)len && chars[pos].isSpace())
             pos++;
         *end = pos;
     } else if (chars[position].isPunct()) {
         int pos = position;
-        while (chars[pos].isPunct() && pos >= 0)
+        while (pos >= 0 && chars[pos].isPunct())
             pos--;
         *start = pos+1;
         pos = position;
-        while (chars[pos].isPunct() && pos < (int)len)
+        while (pos < (int)len && chars[pos].isPunct())
             pos++;
         *end = pos;
     } else {
         int pos = position;
-        while (!chars[pos].isSpace() && !chars[pos].isPunct() && pos >= 0)
+        while (pos >= 0 && !chars[pos].isSpace() && !chars[pos].isPunct())
             pos--;
         *start = pos+1;
         pos = position;
-        while (!chars[pos].isSpace() && !chars[pos].isPunct() && pos < (int)len)
+        while (pos < (int)len && !chars[pos].isSpace() && !chars[pos].isPunct())
             pos++;
         *end = pos;
     }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic