From ffd0b20af745286c3bb2107b5b6c12a355dc4e89 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 16 May 2011 14:44:45 +0200 Subject: COMMON: Don't allocate zero-sized storage in array --- common/array.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common/array.h b/common/array.h index 26ee2afbcc..87325d60d3 100644 --- a/common/array.h +++ b/common/array.h @@ -264,9 +264,13 @@ protected: void allocCapacity(uint capacity) { _capacity = capacity; - _storage = new T[capacity]; - if (!_storage) - ::error("Common::Array: failure to allocate %d bytes", capacity); + if (capacity) { + _storage = new T[capacity]; + if (!_storage) + ::error("Common::Array: failure to allocate %d bytes", capacity); + } else { + _storage = 0; + } } /** -- cgit v1.2.3