diff --git a/src/norm_engine.cpp b/src/norm_engine.cpp index 3fc54390..6f813346 100644 --- a/src/norm_engine.cpp +++ b/src/norm_engine.cpp @@ -415,7 +415,8 @@ void zmq::norm_engine_t::recv_data(NormObjectHandle object) if (NULL == rxState) { // This is a new stream, so create rxState with zmq decoder, etc - rxState = new NormRxStreamState(object, options.maxmsgsize); + rxState = new (std::nothrow) NormRxStreamState(object, options.maxmsgsize); + if (!rxState->Init()) { errno_assert(false); diff --git a/src/socket_base.cpp b/src/socket_base.cpp index bd013f90..f7b5440f 100644 --- a/src/socket_base.cpp +++ b/src/socket_base.cpp @@ -204,9 +204,10 @@ zmq::socket_base_t::socket_base_t (ctx_t *parent_, uint32_t tid_, int sid_, bool options.linger = parent_->get (ZMQ_BLOCKY)? -1: 0; if (thread_safe) - mailbox = new mailbox_safe_t(&sync); + mailbox = new (std::nothrow) mailbox_safe_t(&sync); else { - mailbox_t *m = new mailbox_t(); + mailbox_t *m = new (std::nothrow) mailbox_t(); + if (m->get_fd () != retired_fd) mailbox = m; else { @@ -1298,7 +1299,7 @@ void zmq::socket_base_t::start_reaping (poller_t *poller_) else { scoped_optional_lock_t sync_lock(thread_safe ? &sync : NULL); - reaper_signaler = new signaler_t(); + reaper_signaler = new (std::nothrow) signaler_t(); // Add signaler to the safe mailbox fd = reaper_signaler->get_fd(); diff --git a/src/zmq.cpp b/src/zmq.cpp index 9a0de548..cc9945df 100644 --- a/src/zmq.cpp +++ b/src/zmq.cpp @@ -757,7 +757,7 @@ inline int zmq_poller_poll (zmq_pollitem_t *items_, int nitems_, long timeout_) // implement zmq_poll on top of zmq_poller int rc; zmq_poller_event_t *events; - events = new zmq_poller_event_t[nitems_]; + events = new (std::nothrow) zmq_poller_event_t[nitems_]; alloc_assert(events); void *poller = zmq_poller_new (); alloc_assert(poller); diff --git a/src/zmq_utils.cpp b/src/zmq_utils.cpp index 2b7ac18e..88b90344 100644 --- a/src/zmq_utils.cpp +++ b/src/zmq_utils.cpp @@ -36,6 +36,7 @@ #include "atomic_counter.hpp" #include "atomic_ptr.hpp" #include +#include #include #if !defined ZMQ_HAVE_WINDOWS @@ -75,7 +76,7 @@ unsigned long zmq_stopwatch_stop (void *watch_) void *zmq_threadstart(zmq_thread_fn* func, void* arg) { - zmq::thread_t* thread = new zmq::thread_t; + zmq::thread_t* thread = new (std::nothrow) zmq::thread_t; thread->start(func, arg); return thread; } @@ -265,7 +266,7 @@ int zmq_curve_public (char *z85_public_key, const char *z85_secret_key) void *zmq_atomic_counter_new (void) { - zmq::atomic_counter_t *counter = new zmq::atomic_counter_t; + zmq::atomic_counter_t *counter = new (std::nothrow) zmq::atomic_counter_t; alloc_assert (counter); return counter; }