diff --git a/Eigen/src/SparseCore/CompressedStorage.h b/Eigen/src/SparseCore/CompressedStorage.h index 5af270bc5..d667944ce 100644 --- a/Eigen/src/SparseCore/CompressedStorage.h +++ b/Eigen/src/SparseCore/CompressedStorage.h @@ -229,8 +229,10 @@ class CompressedStorage internal::scoped_array newValues(size); internal::scoped_array newIndices(size); Index copySize = (std::min)(size, m_size); - internal::smart_copy(m_values, m_values+copySize, newValues.ptr()); - internal::smart_copy(m_indices, m_indices+copySize, newIndices.ptr()); + if (copySize>0) { + internal::smart_copy(m_values, m_values+copySize, newValues.ptr()); + internal::smart_copy(m_indices, m_indices+copySize, newIndices.ptr()); + } std::swap(m_values,newValues.ptr()); std::swap(m_indices,newIndices.ptr()); m_allocatedSize = size;