Don't call memcpy with 0 size and NULL pointer(s)

It's undefined behavior, and ubsan flags it.
This commit is contained in:
Brian Silverman
2016-02-05 14:04:22 -05:00
parent c9c9a777d6
commit f4fe375bd1
8 changed files with 18 additions and 9 deletions

View File

@@ -62,7 +62,8 @@ int zmq::sub_t::xsetsockopt (int option_, const void *optval_,
else
if (option_ == ZMQ_UNSUBSCRIBE)
*data = 0;
memcpy (data + 1, optval_, optvallen_);
if (optvallen_ > 0)
memcpy (data + 1, optval_, optvallen_);
// Pass it further on in the stack.
int err = 0;