Problem: malloc may fail in blob_t ctors

Solution: add alloc_assert calls
This commit is contained in:
Simon Giesecke 2018-05-18 13:13:20 +02:00
parent 9da0c6d62f
commit 7b3acd47b2

View File

@ -30,6 +30,8 @@
#ifndef __ZMQ_BLOB_HPP_INCLUDED__ #ifndef __ZMQ_BLOB_HPP_INCLUDED__
#define __ZMQ_BLOB_HPP_INCLUDED__ #define __ZMQ_BLOB_HPP_INCLUDED__
#include "err.hpp"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <algorithm> #include <algorithm>
@ -77,6 +79,7 @@ struct blob_t
size_ (size), size_ (size),
owned_ (true) owned_ (true)
{ {
alloc_assert (data_);
} }
// Creates a blob_t of a given size, an initializes content by copying // Creates a blob_t of a given size, an initializes content by copying
@ -86,6 +89,7 @@ struct blob_t
size_ (size), size_ (size),
owned_ (true) owned_ (true)
{ {
alloc_assert (data_);
memcpy (data_, data, size_); memcpy (data_, data, size_);
} }