mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-03 10:24:44 +00:00
Add len check for newIfStmt to avoid segfault (#11032)
This commit is contained in:
committed by
Andreas Rumpf
parent
e2848ccd2b
commit
a68c5662f2
@@ -1105,6 +1105,8 @@ proc newIfStmt*(branches: varargs[tuple[cond, body: NimNode]]):
|
||||
## )
|
||||
##
|
||||
result = newNimNode(nnkIfStmt)
|
||||
if len(branches) < 1:
|
||||
error("If statement must have at least one branch")
|
||||
for i in branches:
|
||||
result.add(newTree(nnkElifBranch, i.cond, i.body))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user