From 6515577dc3cca271224ea9503f2d02b1b08feb05 Mon Sep 17 00:00:00 2001 From: Takatoshi Kondo Date: Sun, 2 Feb 2014 17:28:33 +0000 Subject: [PATCH] Added null pointer check for C++ separated code. --- cpp11/zone.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cpp11/zone.hpp b/cpp11/zone.hpp index c86a3304..a5635450 100644 --- a/cpp11/zone.hpp +++ b/cpp11/zone.hpp @@ -230,8 +230,13 @@ inline void* zone::allocate_expand(size_t size) } chunk* c = static_cast(::malloc(sizeof(chunk) + sz)); + if (!c) return nullptr; char* ptr = reinterpret_cast(c) + sizeof(chunk); + if (!ptr) { + ::free(c); + return nullptr; + } c->next_ = cl->head_; cl->head_ = c;