Skip to content

Commit

Permalink
fix: crash when checking for pragmas and docs in very long procedures
Browse files Browse the repository at this point in the history
FossilOrigin-Name: ce9154a7b54bb2be562784ddbd13f265fca8974a0cc33f245d30e4d8aea41406
  • Loading branch information
thindil committed Jan 29, 2025
1 parent 35700b4 commit 47ffc0e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
11 changes: 7 additions & 4 deletions src/rules/hasdoc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,13 @@ checkRule:
return
try:
let routineHash: Hash = hash(x = nodeName & $node[paramsPos])
if ($node[bodyPos]).len == 0:
checked.add(y = routineHash)
elif routineHash in checked:
continue
try:
if ($node[bodyPos]).len == 0:
checked.add(y = routineHash)
elif routineHash in checked:
continue
except Exception:
discard
except Exception:
rule.amount = errorMessage(
text = "Can't check if thing is a forward declaration.")
Expand Down
17 changes: 10 additions & 7 deletions src/rules/haspragma.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2023-2024 Bartek Jasicki
# Copyright © 2023-2025 Bartek Jasicki
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -161,13 +161,16 @@ checkRule:
return
try:
let routineHash: Hash = hash(x = procName & $node[paramsPos])
if ($node[bodyPos]).len == 0:
checked.add(y = routineHash)
elif routineHash in checked:
continue
try:
if ($node[bodyPos]).len == 0:
checked.add(y = routineHash)
elif routineHash in checked:
continue
except Exception:
discard
except Exception:
rule.amount = errorMessage(
text = "Can't check if thing is a forward declaration.")
rule.amount = errorMessage(text = "Can't check if thing is a forward declaration.",
e = getCurrentException())
return
# The node doesn't have any pragmas
if pragmas == nil:
Expand Down

0 comments on commit 47ffc0e

Please sign in to comment.