0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-27 07:31:03 +08:00

Problem: inconsistent behaviour of zmq_poller_add and zmq_poller_add_fd in case of memory exhaustion

Solution: always return -1 with errno == ENOMEM
This commit is contained in:
Simon Giesecke 2018-05-13 18:06:05 +02:00
parent 0a037a7431
commit 00d25b7873

View File

@ -137,7 +137,13 @@ int zmq::socket_poller_t::add (socket_base_t *socket_,
-1
#endif
};
items.push_back (item);
try {
items.push_back (item);
}
catch (const std::bad_alloc &) {
errno = ENOMEM;
return -1;
}
need_rebuild = true;
return 0;
@ -162,7 +168,13 @@ int zmq::socket_poller_t::add_fd (fd_t fd_, void *user_data_, short events_)
-1
#endif
};
items.push_back (item);
try {
items.push_back (item);
}
catch (const std::bad_alloc &) {
errno = ENOMEM;
return -1;
}
need_rebuild = true;
return 0;