1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Revert "thread.c (rb_wait_for_single_fd): no point initializing pollfd.revents"

It may cause an access to uninitialized variables.
The call to ppoll will set the `revents` field, but ppoll is not always
called because it is in the guard `!RUBY_VM_INTERRUPTED(th->ec)`.
This issue was found by Coverity Scan.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2018-11-06 22:55:57 +00:00
parent e6bf368cac
commit 9c40a9545a

View file

@ -4043,10 +4043,12 @@ rb_wait_for_single_fd(int fd, int events, struct timeval *timeout)
fds[0].fd = fd;
fds[0].events = (short)events;
do {
fds[0].revents = 0;
fds[1].fd = rb_sigwait_fd_get(th);
if (fds[1].fd >= 0) {
fds[1].events = POLLIN;
fds[1].revents = 0;
nfds = 2;
ubf = ubf_sigwait;
}
@ -4070,6 +4072,7 @@ rb_wait_for_single_fd(int fd, int events, struct timeval *timeout)
if (fds[1].fd >= 0) {
if (result > 0 && fds[1].revents) {
result--;
fds[1].revents = 0;
}
(void)check_signals_nogvl(th, fds[1].fd);
rb_sigwait_fd_put(th, fds[1].fd);