1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os: fix file read (#10247)

This commit is contained in:
Uwe Krüger
2021-05-29 15:53:42 +02:00
committed by GitHub
parent 15557161cc
commit 2d8a136d6e
2 changed files with 6 additions and 6 deletions

View File

@@ -49,7 +49,7 @@ pub fn fd_read(fd int, maxbytes int) (string, int) {
return '', 0
}
unsafe {
mut buf := malloc(maxbytes)
mut buf := malloc(maxbytes + 1)
nbytes := C.read(fd, buf, maxbytes)
if nbytes < 0 {
free(buf)