mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-10 07:56:09 +00:00
check for potential unsigned integer wraparound before adding
This commit is contained in:
parent
7701a8f936
commit
2182bc963d
@ -103,8 +103,9 @@ int zmq::msg_t::init_size (size_t size_)
|
|||||||
u.lmsg.type = type_lmsg;
|
u.lmsg.type = type_lmsg;
|
||||||
u.lmsg.flags = 0;
|
u.lmsg.flags = 0;
|
||||||
u.lmsg.routing_id = 0;
|
u.lmsg.routing_id = 0;
|
||||||
u.lmsg.content =
|
u.lmsg.content = NULL;
|
||||||
(content_t*) malloc (sizeof (content_t) + size_);
|
if (sizeof (content_t) + size_ > size_)
|
||||||
|
u.lmsg.content = (content_t*) malloc (sizeof (content_t) + size_);
|
||||||
if (unlikely (!u.lmsg.content)) {
|
if (unlikely (!u.lmsg.content)) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user