summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-01-27 20:25:37 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-01-27 20:25:37 +0800
commit6a2249c865914658e57557dbd91241e4a73ace07 (patch)
treeed439d7ed407b08f4da3b1b5fef0fe785703b194
parent95151f0cb92f882c959e40139abf94a4fe1ca7b8 (diff)
downloadlua-language-server-6a2249c865914658e57557dbd91241e4a73ace07.zip
fix depth limit
-rw-r--r--script/parser/guide.lua28
1 files changed, 20 insertions, 8 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index 3e2fb69b..ba30bcbc 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -1411,7 +1411,23 @@ function m.checkSameSimpleInValueOfTable(status, value, start, pushQueue)
end
end
+function m.checkStatusDepth(status)
+ if status.depth <= 20 then
+ return true
+ end
+ if m.debugMode then
+ error('status.depth overflow')
+ elseif DEVELOP then
+ --log.warn(debug.traceback('status.depth overflow'))
+ logWarn('status.depth overflow')
+ end
+ return false
+end
+
function m.searchFields(status, obj, key)
+ if not m.checkStatusDepth(status) then
+ return
+ end
local simple = m.getSimple(obj)
if not simple then
return
@@ -1422,6 +1438,9 @@ function m.searchFields(status, obj, key)
end
function m.searchDefFields(status, obj, key)
+ if not m.checkStatusDepth(status) then
+ return
+ end
local simple = m.getSimple(obj)
if not simple then
return
@@ -2912,18 +2931,11 @@ function m.searchRefs(status, obj, mode)
tracy.ZoneEnd()
-- 检查simple
tracy.ZoneBeginN('searchRefs searchSameFields')
- if status.depth <= 20 then
+ if m.checkStatusDepth(status) then
local simple = m.getSimple(obj)
if simple then
m.searchSameFields(status, simple, mode)
end
- else
- if m.debugMode then
- error('status.depth overflow')
- elseif DEVELOP then
- --log.warn(debug.traceback('status.depth overflow'))
- logWarn('status.depth overflow')
- end
end
tracy.ZoneEnd()