Bug #1600

CParser::IsNumber can return wrong result

Added by cbpporter cbpporter about 7 years ago. Updated about 7 years ago.

Status:ApprovedStart date:01/03/2017
Priority:LowDue date:
Assignee:-% Done:


Category:CoreSpent time:-
Target version:-


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.


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.


#1 Updated by cbpporter cbpporter about 7 years ago

  • Category set to Core

#2 Updated by Miroslav Fidler about 7 years ago

  • Status changed from New to Approved

Also available in: Atom PDF