Merge pull request #401 from gummif/gfa/msg-ub

Problem: UB in message_t constructor
This commit is contained in:
Simon Giesecke 2020-05-14 12:04:22 +02:00 committed by GitHub
commit a6ca65cbfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -365,7 +365,12 @@ class message_t
int rc = zmq_msg_init_size(&msg, size_);
if (rc != 0)
throw error_t();
memcpy(data(), data_, size_);
if (size_)
{
// this constructor allows (nullptr, 0),
// memcpy with a null pointer is UB
memcpy(data(), data_, size_);
}
}
message_t(void *data_, size_t size_, free_fn *ffn_, void *hint_ = ZMQ_NULLPTR)