summary refs log tree commit diff stats
path: root/lib/system.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system.nim')
-rw-r--r--lib/system.nim1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim
index 52ed524be..832a98976 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -4112,6 +4112,7 @@ template once*(body: untyped): untyped =
 {.pop.} #{.push warning[GcMem]: off, warning[Uninit]: off.}
 
 proc substr*(s: string, first, last: int): string =
+  let first = max(first, 0)
   let L = max(min(last, high(s)) - first + 1, 0)
   result = newString(L)
   for i in 0 .. L-1: