Bug #1600
CParser::IsNumber can return wrong result
Status: | Approved | Start date: | 01/03/2017 | |
---|---|---|---|---|
Priority: | Low | Due date: | ||
Assignee: | - | % Done: | 0% | |
Category: | Core | Spent time: | - | |
Target version: | - |
Description
CParser::IsNumber takes a base parameter, so I interpreted the function as being designed as "is the contents of the stream in the parser a number using base XXX?".
If this assertion is true, IsNumber(8) on a stream with the contents "9 ..." will return true, which should be false.
Fix:
bool CParser::IsNumber(int base) const { if(IsDigit(*term)) { int q = *term - '0'; return q >= 0 && q < base; } else { int q = ToUpper(*term) - 'A'; return q >= 0 && q < base - 10; } }
The fix is a bit slower, but I doubt this will have real life impact.
History
#1 Updated by cbpporter cbpporter over 7 years ago
- Category set to Core
#2 Updated by Miroslav Fidler over 7 years ago
- Status changed from New to Approved