Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 92ec87d

Browse files
author
Dave
committedDec 20, 2015
uv__fs_buf_iter: don't nullify req->bufs on EINTR
uv__fs_buf_iter currently sets req->bufs to NULL after it is done, but if the operation fails with EINTR then it will be retried, at which point it expects the bufs to not be NULL, causing a seg fault as in nodejs/node#4291. uv__fs_buf_iter should not set req->bufs to NULL if the operation fails with EINTR. Also, when it sets req->bufs to NULL, it should set req->nbufs to 0 as well, so we don't have the messy situation of a positive nbufs with no actual bufs.
1 parent c861972 commit 92ec87d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎src/unix/fs.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,11 @@ static ssize_t uv__fs_buf_iter(uv_fs_t* req, uv__fs_buf_iter_processor process)
860860

861861
if (bufs != req->bufsml)
862862
uv__free(bufs);
863-
req->bufs = NULL;
863+
864+
if (errno != EINTR && total != -1) {
865+
req->bufs = NULL;
866+
req->nbufs = 0;
867+
}
864868

865869
return total;
866870
}

0 commit comments

Comments
 (0)
Please sign in to comment.