Skip to content

NumberParser::parse raise a debug assertion  #2441

@fenghao119

Description

@fenghao119

Expected behavior

Poco::NumberParser::parse a invalid integer string, it should throw execption.

Actual behavior

raise a debug assertion

Steps to reproduce the problem

(please make this a SSCCE, if applicable and reasonable)

void testParseUTF8()
{
	const char test[] = { -23, -108, -103, -24, -81, -81, 0 };
	Poco::NumberParser::parse(test); // raise debug assertion
}

assert by

extern "C" int __cdecl _chvalidator(int const c, int const mask)
{
  _ASSERTE(c >= -1 && c <= 255);
  return _chvalidator_l(nullptr, c, mask);
}

call stack

ucrtbased.dll!_chvalidator(int c, int mask) line 36	C++
ucrtbased.dll!fast_check(const int c, const int mask) line 24	C++
ucrtbased.dll!isspace(int c) line 107	C++
PocoFoundation64d.dll!Poco::strToInt<int>(const char * pStr, int & result, short base, char thSep) line 88	C++
PocoFoundation64d.dll!Poco::NumberParser::tryParse(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & s, int & value, char thSep) line 54	C++
PocoFoundation64d.dll!Poco::NumberParser::parse(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & s, char thSep) line 44	C++

POCO version

1.9.0

Compiler and version

visual studio community 2017

Operating system and version

Windows 10 home

Other relevant information

from: https://msdn.microsoft.com/en-us/library/y13z34da.aspx

The behavior of isspace and _isspace_l is undefined if c is not EOF or in the range 0 through 0xFF, inclusive. When a debug CRT library is used and c is not one of these values, the functions raise an assertion.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions