[Issue 202] New: std.uni.isUniAlpha() uses a broken binary search

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 17 08:07:25 PDT 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 at digitalmars.com
        ReportedBy: deewiant at 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.


-- 




More information about the Digitalmars-d-bugs mailing list