Skip to content

Commit fe13737

Browse files
committed
fix(parser): ensure std::isdigit() is called with an unsigned char
1 parent ad571f0 commit fe13737

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

includes/sjson/parser.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -717,9 +717,9 @@ namespace sjson
717717
{
718718
advance();
719719
}
720-
else if (std::isdigit(m_state.symbol))
720+
else if (std::isdigit(static_cast<unsigned char>(m_state.symbol)))
721721
{
722-
while (std::isdigit(m_state.symbol))
722+
while (std::isdigit(static_cast<unsigned char>(m_state.symbol)))
723723
advance();
724724
}
725725
else
@@ -732,7 +732,7 @@ namespace sjson
732732
{
733733
advance();
734734

735-
while (std::isdigit(m_state.symbol))
735+
while (std::isdigit(static_cast<unsigned char>(m_state.symbol)))
736736
advance();
737737
}
738738

@@ -744,13 +744,13 @@ namespace sjson
744744
{
745745
advance();
746746
}
747-
else if (!std::isdigit(m_state.symbol))
747+
else if (!std::isdigit(static_cast<unsigned char>(m_state.symbol)))
748748
{
749749
set_error(ParserError::InvalidNumber);
750750
return false;
751751
}
752752

753-
while (std::isdigit(m_state.symbol))
753+
while (std::isdigit(static_cast<unsigned char>(m_state.symbol)))
754754
advance();
755755
}
756756

@@ -811,13 +811,13 @@ namespace sjson
811811
{
812812
base = 8;
813813

814-
while (std::isdigit(m_state.symbol))
814+
while (std::isdigit(static_cast<unsigned char>(m_state.symbol)))
815815
advance();
816816
}
817817
}
818-
else if (std::isdigit(m_state.symbol))
818+
else if (std::isdigit(static_cast<unsigned char>(m_state.symbol)))
819819
{
820-
while (std::isdigit(m_state.symbol))
820+
while (std::isdigit(static_cast<unsigned char>(m_state.symbol)))
821821
advance();
822822
}
823823
else
@@ -902,7 +902,7 @@ namespace sjson
902902

903903
static bool is_hex_digit(char value)
904904
{
905-
return std::isdigit(value)
905+
return std::isdigit(static_cast<unsigned char>(value))
906906
|| value == 'a' || value == 'A'
907907
|| value == 'b' || value == 'B'
908908
|| value == 'c' || value == 'C'

0 commit comments

Comments
 (0)