Skip to content

Commit 35ff8ad

Browse files
authored
Raise preprocessor timeout to 0.5 from 0.1 + minor changes (#3617)
* First small preprocessor changes * Raise preprocessor timeout to 0.5 from 0.1
1 parent e4113ad commit 35ff8ad

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

lua/entities/gmod_wire_expression2/base/preprocessor.lua

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -403,27 +403,26 @@ function PreProcessor:Process(buffer, directives, ent)
403403
self.ignorestuff = true
404404
end
405405

406-
-- to avoid hangs
407-
local start_time = SysTime()
406+
-- to avoid big hangs, 2 regex changed from 500 to 10000 to avoid false positives
407+
local regex_limits = {[0] = 50000000, 15000, 10000, 150, 70, 40}
408+
local timeout = SysTime() + 0.5
408409

409410
for i, line in ipairs(lines) do
410411
self.readline = i
411412

412-
-- 2 regex changed from 500 to 10000, to avoid hangs
413-
local ok = pcall(function() WireLib.CheckRegex(line, "^(.-)%s*$", {[0] = 50000000, 15000, 10000, 150, 70, 40}) end)
413+
local ok = pcall(function() WireLib.CheckRegex(line, "^(.-)%s*$", regex_limits) end)
414414
if not ok then self:Error("Line strip regex is too complex!") goto cont end
415415

416-
if SysTime() > start_time + 0.1 then
417-
self:Error("Preprocessing take too long!")
418-
break
419-
end
420-
421416
line = string.TrimRight(line)
422417
line = self:RemoveComments(line)
423418
line = self:ParseDirectives(line)
424-
425419
lines[i] = line
426420
::cont::
421+
422+
if SysTime() > timeout then
423+
self:Error("Preprocessing took too long!")
424+
break
425+
end
427426
end
428427

429428
-- convert description lookup table into an array that WireLib understands

0 commit comments

Comments
 (0)