diff options
author | 2014-12-11 16:15:20 +0100 | |
---|---|---|
committer | 2014-12-11 16:15:20 +0100 | |
commit | 0efaff9b3b261daaa91baf8935ec7c4f5156a647 (patch) | |
tree | fd1547eeaf6adcaa20299d454573a8bc7f5be5f1 /Eigen/src | |
parent | 41a20994cce4d7e2c49bbb958a43c9ed69473f7f (diff) |
Fix out-of-bounds write
Diffstat (limited to 'Eigen/src')
-rw-r--r-- | Eigen/src/SparseCore/AmbiVector.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Eigen/src/SparseCore/AmbiVector.h b/Eigen/src/SparseCore/AmbiVector.h index 5c9c3101e..76ef25f7d 100644 --- a/Eigen/src/SparseCore/AmbiVector.h +++ b/Eigen/src/SparseCore/AmbiVector.h @@ -69,7 +69,7 @@ class AmbiVector delete[] m_buffer; if (size<1000) { - Index allocSize = (size * sizeof(ListEl))/sizeof(Scalar); + Index allocSize = (size * sizeof(ListEl) + sizeof(Scalar) - 1)/sizeof(Scalar); m_allocatedElements = (allocSize*sizeof(Scalar))/sizeof(ListEl); m_buffer = new Scalar[allocSize]; } @@ -88,7 +88,7 @@ class AmbiVector Index copyElements = m_allocatedElements; m_allocatedElements = (std::min)(Index(m_allocatedElements*1.5),m_size); Index allocSize = m_allocatedElements * sizeof(ListEl); - allocSize = allocSize/sizeof(Scalar) + (allocSize%sizeof(Scalar)>0?1:0); + allocSize = (allocSize + sizeof(Scalar) - 1)/sizeof(Scalar); Scalar* newBuffer = new Scalar[allocSize]; memcpy(newBuffer, m_buffer, copyElements * sizeof(ListEl)); delete[] m_buffer; |