mirror of
https://github.com/zeromq/cppzmq.git
synced 2025-06-26 14:34:04 +02:00
Problem: UB in message_t constructor
Solution: Add check to guard against passing null to memcpy
This commit is contained in:
parent
a3e5b54c3c
commit
1793a5b586
7
zmq.hpp
7
zmq.hpp
@ -365,7 +365,12 @@ class message_t
|
|||||||
int rc = zmq_msg_init_size(&msg, size_);
|
int rc = zmq_msg_init_size(&msg, size_);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
throw error_t();
|
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)
|
message_t(void *data_, size_t size_, free_fn *ffn_, void *hint_ = ZMQ_NULLPTR)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user