Skip to content

Commit 2f1fd82

Browse files
committed
Limit line numbers to Location::line max value
1 parent f2bd340 commit 2f1fd82

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

simplecpp.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,11 +746,14 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
746746
if (!ppTok || !ppTok->number)
747747
continue;
748748

749+
constexpr auto line_limit = std::numeric_limits<decltype(Location::line)>::max();
749750
unsigned long line;
750751
try {
751752
line = std::stoul(ppTok->str());
753+
if (line > line_limit)
754+
line = line_limit;
752755
} catch (...) {
753-
line = std::numeric_limits<unsigned long>::max();
756+
line = line_limit;
754757
}
755758

756759
unsigned long maxline;

0 commit comments

Comments
 (0)