Fix two memory issues discovered by valgrind

This commit is contained in:
Ian Gulliver
2019-05-04 07:39:12 +00:00
parent ac0d3e2816
commit c1b0a1dcce
2 changed files with 4 additions and 3 deletions

View File

@@ -35,7 +35,7 @@ class Buffer : public ConstBuffer {
void Consume(); // discard up to last commit
protected:
std::unique_ptr<char> own_buf_;
std::unique_ptr<char[]> own_buf_;
char *buf_;
const size_t size_;
};

View File

@@ -49,8 +49,9 @@ FastCGIServer::FastCGIServer(int port, const std::function<void(std::unique_ptr<
void FastCGIServer::Serve() {
while (true) {
struct epoll_event events[256];
auto num_fd = epoll_wait(epoll_fd_, events, sizeof(events), -1);
constexpr auto max_events = 256;
struct epoll_event events[max_events];
auto num_fd = epoll_wait(epoll_fd_, events, max_events, -1);
if (num_fd == -1 && errno == EINTR) {
continue;
}