From a68c5662f2e3fa732a330ff373cf224495472372 Mon Sep 17 00:00:00 2001 From: Jasper Jenkins Date: Mon, 15 Apr 2019 08:02:25 -0700 Subject: Add len check for newIfStmt to avoid segfault (#11032) --- lib/core/macros.nim | 2 ++ 1 file changed, 2 insertions(+) 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)) -- cgit 1.4.1-2-gfad0