From 9fae86912423da923421067dbcd360cf5121bd27 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Mon, 22 Dec 2014 17:59:59 +0300 Subject: [PATCH] Pre-asserts to ensure no overflow happens --- tinyxml2.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tinyxml2.h b/tinyxml2.h index dd1b2cd..35da4d9 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -288,7 +288,9 @@ public: private: void EnsureCapacity( int cap ) { + TIXMLASSERT( cap > 0 ); if ( cap > _allocated ) { + TIXMLASSERT( cap <= INT_MAX / 2 ); int newAllocated = cap * 2; T* newMem = new T[newAllocated]; memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs