Fix bug #884: No malloc for zero-sized matrices or for Ref without temporaries

manually ported from 4ba8aa1482
This commit is contained in:
Christoph Hertzberg
2014-09-25 16:25:31 +02:00
parent 91f1a161ca
commit e395a8042a
2 changed files with 36 additions and 1 deletions

View File

@@ -417,6 +417,8 @@ template<typename T, bool Align> inline T* conditional_aligned_realloc_new(T* pt
template<typename T, bool Align> inline T* conditional_aligned_new_auto(size_t size)
{
if(size==0)
return 0; // short-cut. Also fixes Bug 884
check_size_for_overflow<T>(size);
T *result = reinterpret_cast<T*>(conditional_aligned_malloc<Align>(sizeof(T)*size));
if(NumTraits<T>::RequireInitialization)