[Scummvm-cvs-logs] scummvm master -> ffd0b20af745286c3bb2107b5b6c12a355dc4e89

wjp wjp at usecode.org
Mon May 16 14:49:06 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
ffd0b20af7 COMMON: Don't allocate zero-sized storage in array


Commit: ffd0b20af745286c3bb2107b5b6c12a355dc4e89
    https://github.com/scummvm/scummvm/commit/ffd0b20af745286c3bb2107b5b6c12a355dc4e89
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-05-16T05:44:45-07:00

Commit Message:
COMMON: Don't allocate zero-sized storage in array

Changed paths:
    common/array.h



diff --git a/common/array.h b/common/array.h
index 26ee2af..87325d6 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;
+		}
 	}
 
 	/**






More information about the Scummvm-git-logs mailing list