Help markup parser: Avoid UB and unused param when checking closing tag
This commit is contained in:
parent
2e3c401f45
commit
62c03ad779
1 changed files with 10 additions and 1 deletions
|
@ -1582,11 +1582,20 @@ static std::pair<std::string, std::string> parse_attribute(std::string::const_it
|
|||
|
||||
static void check_closing_tag(std::string::const_iterator& beg, std::string::const_iterator end, std::string_view match)
|
||||
{
|
||||
size_t remaining = end - beg;
|
||||
assert(remaining >= 2 && *beg == '<' && *(beg + 1) == '/');
|
||||
if(remaining < match.size() + 3) {
|
||||
throw parse_error("Unexpected eos in closing tag");
|
||||
}
|
||||
beg += 2;
|
||||
if(!std::equal(match.begin(), match.end(), beg)) {
|
||||
throw parse_error("Mismatched closing tag");
|
||||
}
|
||||
beg += match.size() + 1;
|
||||
beg += match.size();
|
||||
if(*beg != '>') {
|
||||
throw parse_error("Unterminated closing tag");
|
||||
}
|
||||
++beg;
|
||||
}
|
||||
|
||||
static std::pair<std::string, config> parse_tag(std::string::const_iterator& beg, std::string::const_iterator end);
|
||||
|
|
Loading…
Add table
Reference in a new issue