diff --git a/RELICENSE/casaroli.md b/RELICENSE/casaroli.md new file mode 100644 index 00000000..97ea9285 --- /dev/null +++ b/RELICENSE/casaroli.md @@ -0,0 +1,16 @@ +# Permission to Relicense under MPLv2 or any other OSI approved license chosen by the current ZeroMQ BDFL + +This is a statement by Marco Casaroli that grants permission to +relicense its copyrights in the libzmq C++ library (ZeroMQ) under the +Mozilla Public License v2 (MPLv2) or any other Open Source Initiative +approved license chosen by the current ZeroMQ BDFL (Benevolent +Dictator for Life). + +A portion of the commits made by the Github handle "casaroli", with +commit author "Marco Casaroli ", are +copyright of Marco Casaroli. This document hereby grants the libzmq +project team to relicense libzmq, including all past, present and +future contributions of the author listed above. + +Marco Casaroli +2023/2/2 diff --git a/src/blob.hpp b/src/blob.hpp index 06a41913..d84bba64 100644 --- a/src/blob.hpp +++ b/src/blob.hpp @@ -81,7 +81,7 @@ struct blob_t _size (size_), _owned (true) { - alloc_assert (_data); + alloc_assert (!_size || _data); } // Creates a blob_t of a given size, an initializes content by copying @@ -91,8 +91,10 @@ struct blob_t _size (size_), _owned (true) { - alloc_assert (_data); - memcpy (_data, data_, size_); + alloc_assert (!size_ || _data); + if (size_ && _data) { + memcpy (_data, data_, size_); + } } // Creates a blob_t for temporary use that only references a @@ -126,10 +128,12 @@ struct blob_t { clear (); _data = static_cast (malloc (other_._size)); - alloc_assert (_data); + alloc_assert (!other_._size || _data); _size = other_._size; _owned = true; - memcpy (_data, other_._data, _size); + if (_size && _data) { + memcpy (_data, other_._data, _size); + } } // Sets a blob_t to a copy of a given buffer. @@ -137,10 +141,12 @@ struct blob_t { clear (); _data = static_cast (malloc (size_)); - alloc_assert (_data); + alloc_assert (!size_ || _data); _size = size_; _owned = true; - memcpy (_data, data_, size_); + if (size_ && _data) { + memcpy (_data, data_, size_); + } } // Empties a blob_t. diff --git a/src/err.hpp b/src/err.hpp index 3f3278f8..c283e6a5 100644 --- a/src/err.hpp +++ b/src/err.hpp @@ -172,7 +172,7 @@ int wsa_error_to_errno (int errcode_); // Provides convenient way to check whether memory allocation have succeeded. #define alloc_assert(x) \ do { \ - if (unlikely (!x)) { \ + if (unlikely (!(x))) { \ fprintf (stderr, "FATAL ERROR: OUT OF MEMORY (%s:%d)\n", __FILE__, \ __LINE__); \ fflush (stderr); \