Bug 202 – std.uni.isUniAlpha() uses a broken binary search
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
phobos
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-06-17T10:07:00Z
Last change time
2014-02-15T13:28:51Z
Keywords
ice-on-valid-code, patch
Assigned to
bugzilla
Creator
matti.niemenmaa+dbugzilla
Comments
Comment #0 by matti.niemenmaa+dbugzilla — 2006-06-17T10:07:23Z
(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.
Comment #1 by benoit — 2006-06-18T13:53:07Z
*** Bug 207 has been marked as a duplicate of this bug. ***