Fix IndexDefect in asyncfile.readLine (#22774)

`readLine` proc in asyncfile module caused IndexDefect when it reached
EoF. Now it returns empty string instead.
This commit is contained in:
CMD
2023-10-01 08:20:43 +03:00
committed by GitHub
parent b60f15e0dc
commit 49df69334e

View File

@@ -301,6 +301,8 @@ proc readLine*(f: AsyncFile): Future[string] {.async.} =
result = ""
while true:
var c = await read(f, 1)
if c.len == 0:
break
if c[0] == '\c':
c = await read(f, 1)
break