diff options
author | Jasper Jenkins <jasper.vs.jenkins@gmail.com> | 2019-04-15 08:02:25 -0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-04-15 17:02:25 +0200 |
commit | a68c5662f2e3fa732a330ff373cf224495472372 (patch) | |
tree | 1aa1c73d0c846049d008f01371c4de1cfba9ffb8 /lib/core | |
parent | e2848ccd2bb1da93d729a6dffb201cea80b9cae4 (diff) | |
download | Nim-a68c5662f2e3fa732a330ff373cf224495472372.tar.gz |
Add len check for newIfStmt to avoid segfault (#11032)
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/macros.nim | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index d27d97f2f..7a8755299 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -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)) |