aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2011-05-16 14:44:45 +0200
committerWillem Jan Palenstijn2011-05-16 14:44:45 +0200
commitffd0b20af745286c3bb2107b5b6c12a355dc4e89 (patch)
tree1b1cbae422ddaaadadf6880c1ec36b4677d55de5 /common
parent9081ab440242da4e3e7373f0d044c7373f97b5dc (diff)
downloadscummvm-rg350-ffd0b20af745286c3bb2107b5b6c12a355dc4e89.tar.gz
scummvm-rg350-ffd0b20af745286c3bb2107b5b6c12a355dc4e89.tar.bz2
scummvm-rg350-ffd0b20af745286c3bb2107b5b6c12a355dc4e89.zip
COMMON: Don't allocate zero-sized storage in array
Diffstat (limited to 'common')
-rw-r--r--common/array.h10
1 files 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;
+ }
}
/**