temporary_buffer: fix wrong oom check

If malloc(0) is allowed to return nullptr, so don't throw an exception in
that case.
This commit is contained in:
Avi Kivity
2014-12-10 10:33:29 +02:00
parent 9aadcb7718
commit fa5c61d4e4

View File

@@ -20,7 +20,7 @@ public:
explicit temporary_buffer(size_t size)
: _buffer(static_cast<CharType*>(malloc(size * sizeof(CharType)))), _size(size)
, _deleter(make_free_deleter(_buffer)) {
if (!_buffer) {
if (size && !_buffer) {
throw std::bad_alloc();
}
}