diff options
author | CMD <48290258+cmd410@users.noreply.github.com> | 2023-10-01 08:20:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-01 07:20:43 +0200 |
commit | 49df69334e8c81354d604bbde05665d6c5450ddb (patch) | |
tree | 7b6c634f67e2f9dc0ec3b380d7df46f90c38c300 | |
parent | b60f15e0dcfd514521bfc2e33c6f2728f565bc9d (diff) | |
download | Nim-49df69334e8c81354d604bbde05665d6c5450ddb.tar.gz |
Fix IndexDefect in asyncfile.readLine (#22774)
`readLine` proc in asyncfile module caused IndexDefect when it reached EoF. Now it returns empty string instead.
-rw-r--r-- | lib/pure/asyncfile.nim | 2 |
1 files changed, 2 insertions, 0 deletions
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 |