diff --git a/src/msgpack/vrefbuffer.hpp b/src/msgpack/vrefbuffer.hpp index 82335277..3017eca1 100644 --- a/src/msgpack/vrefbuffer.hpp +++ b/src/msgpack/vrefbuffer.hpp @@ -29,7 +29,9 @@ public: vrefbuffer(size_t ref_size = MSGPACK_VREFBUFFER_REF_SIZE, size_t chunk_size = MSGPACK_VREFBUFFER_CHUNK_SIZE) { - msgpack_vrefbuffer_init(this, ref_size, chunk_size); + if (!msgpack_vrefbuffer_init(this, ref_size, chunk_size)) { + throw std::bad_alloc(); + } } ~vrefbuffer() diff --git a/src/msgpack/zbuffer.hpp b/src/msgpack/zbuffer.hpp index 08e6fd03..4ccb487b 100644 --- a/src/msgpack/zbuffer.hpp +++ b/src/msgpack/zbuffer.hpp @@ -29,7 +29,9 @@ public: zbuffer(int level = Z_DEFAULT_COMPRESSION, size_t init_size = MSGPACK_ZBUFFER_INIT_SIZE) { - msgpack_zbuffer_init(this, level, init_size); + if (!msgpack_zbuffer_init(this, level, init_size)) { + throw std::bad_alloc(); + } } ~zbuffer()