From fa5c61d4e4d012476bcff0836f8b2db889bd0165 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Wed, 10 Dec 2014 10:33:29 +0200 Subject: [PATCH] temporary_buffer: fix wrong oom check If malloc(0) is allowed to return nullptr, so don't throw an exception in that case. --- core/temporary_buffer.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/temporary_buffer.hh b/core/temporary_buffer.hh index d7c5033f1a..a15c2071e0 100644 --- a/core/temporary_buffer.hh +++ b/core/temporary_buffer.hh @@ -20,7 +20,7 @@ public: explicit temporary_buffer(size_t size) : _buffer(static_cast(malloc(size * sizeof(CharType)))), _size(size) , _deleter(make_free_deleter(_buffer)) { - if (!_buffer) { + if (size && !_buffer) { throw std::bad_alloc(); } }