Bug 9126 – parse!int fails on size_t.max+1 digits long input (overflow)

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-08T23:40:00Z
Last change time
2015-06-09T05:11:41Z
Keywords
pull
Assigned to
nobody
Creator
nilsbossung

Comments

Comment #0 by nilsbossung — 2012-12-08T23:40:03Z
std.conv.parse!int uses a counter just to see if anything could be parsed. When the counter overflows, the state jumps back to "at start", which is wrong, of course. Test case (takes some minutes): --- import std.conv: parse; import std.range: chain, repeat; void main() { auto seven = chain(repeat(cast(dchar) '0', size_t.max), "7"); assert(parse!int(seven) == 7); auto eleven = chain(repeat(cast(dchar) '0', size_t.max), "B"); assert(parse!int(eleven, 13) == 11); } --- Pull request follows.
Comment #1 by nilsbossung — 2012-12-08T23:50:44Z
Comment #2 by github-bugzilla — 2012-12-09T17:50:16Z
Commit pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/dc39ebebdc2cd9db78531bd766c21147ef99cd6f Merge pull request #996 from NilsBossung/parseoverflow Fix Issue 9126 - parse!int fails on size_t.max+1 digits long input (overflow)