Просмотр исходного кода

Merge pull request #552 from Dmitry-Me/ensureNoOverrunBeforeCopy

Ensure no overrun before copying
Lee Thomason 8 лет назад
Родитель
Сommit
33a1f8bd6c
1 измененных файлов с 1 добавлено и 0 удалено
  1. 1 0
      tinyxml2.h

+ 1 - 0
tinyxml2.h

@@ -284,6 +284,7 @@ private:
             TIXMLASSERT( cap <= INT_MAX / 2 );
             int newAllocated = cap * 2;
             T* newMem = new T[newAllocated];
+            TIXMLASSERT( newAllocated >= _size );
             memcpy( newMem, _mem, sizeof(T)*_size );	// warning: not using constructors, only works for PODs
             if ( _mem != _pool ) {
                 delete [] _mem;