diff --git a/lua/entities/gmod_wire_expression2/base/preprocessor.lua b/lua/entities/gmod_wire_expression2/base/preprocessor.lua index 3808c553f2..ca95b7e55b 100644 --- a/lua/entities/gmod_wire_expression2/base/preprocessor.lua +++ b/lua/entities/gmod_wire_expression2/base/preprocessor.lua @@ -403,27 +403,26 @@ function PreProcessor:Process(buffer, directives, ent) self.ignorestuff = true end - -- to avoid hangs - local start_time = SysTime() + -- to avoid big hangs, 2 regex changed from 500 to 10000 to avoid false positives + local regex_limits = {[0] = 50000000, 15000, 10000, 150, 70, 40} + local timeout = SysTime() + 0.5 for i, line in ipairs(lines) do self.readline = i - -- 2 regex changed from 500 to 10000, to avoid hangs - local ok = pcall(function() WireLib.CheckRegex(line, "^(.-)%s*$", {[0] = 50000000, 15000, 10000, 150, 70, 40}) end) + local ok = pcall(function() WireLib.CheckRegex(line, "^(.-)%s*$", regex_limits) end) if not ok then self:Error("Line strip regex is too complex!") goto cont end - if SysTime() > start_time + 0.1 then - self:Error("Preprocessing take too long!") - break - end - line = string.TrimRight(line) line = self:RemoveComments(line) line = self:ParseDirectives(line) - lines[i] = line ::cont:: + + if SysTime() > timeout then + self:Error("Preprocessing took too long!") + break + end end -- convert description lookup table into an array that WireLib understands