Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Handling a couple reasonable error cases

  • Loading branch information...
commit 5f5f0dc966817aafed6901d00ad554c147c6326b 1 parent b6a6abf
@gar1t authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 c_src/erlzmq_nif.c
View
8 c_src/erlzmq_nif.c
@@ -136,7 +136,9 @@ NIF(erlzmq_nif_context)
sizeof(erlzmq_context_t));
assert(context);
context->context_zmq = zmq_init(thread_count);
- assert(context->context_zmq);
+ if (!context->context_zmq) {
+ return return_zmq_errno(env, zmq_errno());
+ }
char thread_socket_id[64];
sprintf(thread_socket_id, "inproc://erlzmq-%ld", (long int) context);
@@ -195,7 +197,9 @@ NIF(erlzmq_nif_socket)
socket->context = context;
socket->socket_index = context->socket_index++;
socket->socket_zmq = zmq_socket(context->context_zmq, socket_type);
- assert(socket->socket_zmq);
+ if (!socket->socket_zmq) {
+ return return_zmq_errno(env, zmq_errno());
+ }
socket->active = active;
socket->mutex = enif_mutex_create("erlzmq_socket_t_mutex");
assert(socket->mutex);
Please sign in to comment.
Something went wrong with that request. Please try again.