From 49df69334e8c81354d604bbde05665d6c5450ddb Mon Sep 17 00:00:00 2001 From: CMD <48290258+cmd410@users.noreply.github.com> Date: Sun, 1 Oct 2023 08:20:43 +0300 Subject: Fix IndexDefect in asyncfile.readLine (#22774) `readLine` proc in asyncfile module caused IndexDefect when it reached EoF. Now it returns empty string instead. --- lib/pure/asyncfile.nim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pure/asyncfile.nim b/lib/pure/asyncfile.nim index 96d5e6d2e..118f94748 100644 --- a/lib/pure/asyncfile.nim +++ b/lib/pure/asyncfile.nim @@ -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 -- cgit 1.4.1-2-gfad0