Thread overview
[Issue 202] New: std.uni.isUniAlpha() uses a broken binary search
Jun 17, 2006
d-bugmail
Jun 18, 2006
d-bugmail
Jun 20, 2006
d-bugmail
June 17, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=202

           Summary: std.uni.isUniAlpha() uses a broken binary search
           Product: D
           Version: 0.160
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-valid-code, patch
          Severity: critical
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: deewiant@gmail.com


(This also applies to the updated std.uni module at http://www.digitalmars.com/d/archives/digitalmars/D/34218.html).

Currently the std.uni.isUniAlpha() function uses a binary search whose while loop is written as "while (low <= high)", but since high is set to mid - 1 and is an unsigned integer, it may overflow if mid is 0. In this case, the while loop will still hold but an array bounds error will occur within the loop.

There are two ways to solve this: the first is to change mid, low, and high from uints to ints - seeing as they go through a table with a compile-time fixed size of only a couple hundred elements this isn't a problem; the second is to change the while loop to "while (low - high <= 0)".

Either way, this needs to be patched. Calling isUniAlpha('4'), for instance, causes an Access Violation.


-- 

June 18, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=202


benoit@tionex.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lio@lunesu.com




------- Comment #1 from benoit@tionex.de  2006-06-18 13:53 -------
*** Bug 207 has been marked as a duplicate of this bug. ***


-- 

June 20, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=202


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from bugzilla@digitalmars.com  2006-06-20 02:23 -------
Fixed DMD 0.161


--