mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-28 11:31:56 +01:00
Don't call memcpy with 0 size and NULL pointer(s)
It's undefined behavior, and ubsan flags it.
This commit is contained in:
@@ -204,7 +204,8 @@ bool zmq::req_t::xhas_out ()
|
||||
int zmq::req_t::xsetsockopt (int option_, const void *optval_, size_t optvallen_)
|
||||
{
|
||||
bool is_int = (optvallen_ == sizeof (int));
|
||||
int value = is_int? *((int *) optval_): 0;
|
||||
int value = 0;
|
||||
if (is_int) memcpy(&value, optval_, sizeof (int));
|
||||
switch (option_) {
|
||||
case ZMQ_REQ_CORRELATE:
|
||||
if (is_int && value >= 0) {
|
||||
|
||||
Reference in New Issue
Block a user