Commit fe9f6b28 authored by Thomas Braun's avatar Thomas Braun

Problem: GSSAPI check for Out of memory is done conditionally

Solution: Do it unconditionally.
parent 19f30f79
...@@ -149,8 +149,9 @@ int zmq::gssapi_mechanism_base_t::decode_message (msg_t *msg_) ...@@ -149,8 +149,9 @@ int zmq::gssapi_mechanism_base_t::decode_message (msg_t *msg_)
// TODO: instead of malloc/memcpy, can we just do: wrapped.value = ptr; // TODO: instead of malloc/memcpy, can we just do: wrapped.value = ptr;
const size_t alloc_length = wrapped.length? wrapped.length: 1; const size_t alloc_length = wrapped.length? wrapped.length: 1;
wrapped.value = static_cast <char *> (malloc (alloc_length)); wrapped.value = static_cast <char *> (malloc (alloc_length));
alloc_assert (wrapped.value);
if (wrapped.length) { if (wrapped.length) {
alloc_assert (wrapped.value);
memcpy(wrapped.value, ptr, wrapped.length); memcpy(wrapped.value, ptr, wrapped.length);
ptr += wrapped.length; ptr += wrapped.length;
bytes_left -= wrapped.length; bytes_left -= wrapped.length;
...@@ -247,9 +248,11 @@ int zmq::gssapi_mechanism_base_t::process_initiate (msg_t *msg_, void **token_va ...@@ -247,9 +248,11 @@ int zmq::gssapi_mechanism_base_t::process_initiate (msg_t *msg_, void **token_va
errno = EPROTO; errno = EPROTO;
return -1; return -1;
} }
*token_value_ = static_cast <char *> (malloc (token_length_ ? token_length_ : 1)); *token_value_ = static_cast <char *> (malloc (token_length_ ? token_length_ : 1));
alloc_assert (*token_value_);
if (token_length_) { if (token_length_) {
alloc_assert (*token_value_);
memcpy(*token_value_, ptr, token_length_); memcpy(*token_value_, ptr, token_length_);
ptr += token_length_; ptr += token_length_;
bytes_left -= token_length_; bytes_left -= token_length_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment