From 3ff3ba83f489e05eecea417d270fc430ecbd6663 Mon Sep 17 00:00:00 2001 From: Takatoshi Kondo Date: Mon, 19 Aug 2013 15:26:12 +0900 Subject: [PATCH] added return value checking. --- src/msgpack/vrefbuffer.hpp | 4 +++- src/msgpack/zbuffer.hpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) 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()