Fix a bus error by not going above an array boundary

This commit is contained in:
Florent Le Coz
2014-03-03 21:02:55 +01:00
parent db6ea52b44
commit 601159e8e2
+2 -1
View File
@@ -183,7 +183,8 @@ void SocketHandler::on_send()
// unconsting the content of s is ok, sendmsg will never modify it // unconsting the content of s is ok, sendmsg will never modify it
msg_iov[msg.msg_iovlen].iov_base = const_cast<char*>(s.data()); msg_iov[msg.msg_iovlen].iov_base = const_cast<char*>(s.data());
msg_iov[msg.msg_iovlen].iov_len = s.size(); msg_iov[msg.msg_iovlen].iov_len = s.size();
msg.msg_iovlen++; if (++msg.msg_iovlen == UIO_FASTIOV)
break;
} }
ssize_t res = ::sendmsg(this->socket, &msg, MSG_NOSIGNAL); ssize_t res = ::sendmsg(this->socket, &msg, MSG_NOSIGNAL);
if (res < 0) if (res < 0)