diff options
| author | nyamatongwe <unknown> | 2007-01-03 09:46:39 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2007-01-03 09:46:39 +0000 | 
| commit | 320192dcb1bbca22f538d7620a9f05e063817946 (patch) | |
| tree | 32118aeb6dd62b9035ddc21bfdbad24dd55b8626 /src/SplitVector.h | |
| parent | 9593abe942596ee72731fadb3eebd4d19b584309 (diff) | |
| download | scintilla-mirror-320192dcb1bbca22f538d7620a9f05e063817946.tar.gz | |
Added range check for InsertValue and some more assertions.
Diffstat (limited to 'src/SplitVector.h')
| -rw-r--r-- | src/SplitVector.h | 8 | 
1 files changed, 8 insertions, 0 deletions
| diff --git a/src/SplitVector.h b/src/SplitVector.h index 46cdc2bbb..e923915d8 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -95,6 +95,8 @@ public:  	/// Retrieve the character at a particular position.  	/// Retrieving positions outside the range of the buffer returns 0. +	/// The assertions here are disabled since calling code can be  +	/// simpler if out of range access works and returns 0.  	T ValueAt(int position) const {  		if (position < part1Length) {  			//PLATFORM_ASSERT(position >= 0); @@ -163,7 +165,11 @@ public:  	/// Insert a number of elements into the buffer setting their value.  	/// Inserting at positions outside the current range fails.  	void InsertValue(int position, int insertLength, T v) { +		PLATFORM_ASSERT((position >= 0) && (position <= lengthBody));  		if (insertLength > 0) { +			if ((position < 0) || (position > lengthBody)) { +				return; +			}  			RoomFor(insertLength);  			GapTo(position);  			for (int i = 0; i < insertLength; i++) @@ -176,6 +182,7 @@ public:  	/// Insert text into the buffer from an array.  	void InsertFromArray(int positionToInsert, const T s[], int positionFrom, int insertLength) { +		PLATFORM_ASSERT((positionToInsert >= 0) && (positionToInsert <= lengthBody));  		if (insertLength > 0) {  			if ((positionToInsert < 0) || (positionToInsert > lengthBody)) {  				return; @@ -191,6 +198,7 @@ public:  	/// Delete one element from the buffer.  	void Delete(int position) { +		PLATFORM_ASSERT((position >= 0) && (position < lengthBody));  		if ((position < 0) || (position >= lengthBody)) {  			return;  		} | 
