summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorFredrik Høisæther Rasch <fredrik.rasch@gmail.com>2017-06-28 18:03:18 +0200
committerFredrik Høisæther Rasch <fredrik.h.rasch@uit.no>2017-07-04 11:52:54 +0200
commit177a634992c378ec331c95e64c7f2ddd73154e77 (patch)
tree55fbb6d118746d711ec9492621493b7a5b9cec19 /lib
parent9823c677b865eb6d491271ec103ecd751da2dde5 (diff)
downloadNim-177a634992c378ec331c95e64c7f2ddd73154e77.tar.gz
Add safeties for alignLeft
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/strutils.nim4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim
index fb52a0cc0..a6bf273b3 100644
--- a/lib/pure/strutils.nim
+++ b/lib/pure/strutils.nim
@@ -1092,8 +1092,8 @@ proc alignLeft*(s: string, count: Natural, padding = ' '): string {.noSideEffect
   ##   assert alignLeft("1232", 6, '#') == "1232##"
   if s.len < count:
     result = newString(count)
-    for i in 0 ..< s.len:
-      result[i] = s[i]
+    if s.len > 0:
+      result[0 .. (s.len - 1)] = s
     for i in s.len ..< count:
       result[i] = padding
   else: