Regex: Limit programs to std::numeric_limits<uint16_t>::max() instructions
This commit is contained in:
parent
8c8dcb3a84
commit
b0233262b8
|
@ -531,6 +531,9 @@ struct RegexCompiler
|
|||
{
|
||||
compile_node(m_parsed_regex.ast);
|
||||
push_inst(CompiledRegex::Match);
|
||||
constexpr auto max_instructions = std::numeric_limits<uint16_t>::max();
|
||||
if (m_program.instructions.size() >= max_instructions)
|
||||
throw regex_error(format("regex compiled to more than {} instructions", max_instructions));
|
||||
m_program.matchers = m_parsed_regex.matchers;
|
||||
m_program.save_count = m_parsed_regex.capture_count * 2;
|
||||
m_program.direction = direction;
|
||||
|
|
|
@ -235,7 +235,7 @@ private:
|
|||
{
|
||||
Vector<Thread> current_threads;
|
||||
Vector<Thread> next_threads;
|
||||
Vector<uint32_t> processed;
|
||||
Vector<uint16_t> processed;
|
||||
};
|
||||
|
||||
enum class StepResult { Consumed, Matched, Failed };
|
||||
|
|
Loading…
Reference in New Issue
Block a user