mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Fix undefined behavior. When resizing a default-constructed SparseArray, we end up calling memcpy(ptr, 0, 0), which is technically UB and gets caught by static analysis.
This commit is contained in:
@@ -208,8 +208,10 @@ class CompressedStorage
|
|||||||
Index* newIndices = new Index[size];
|
Index* newIndices = new Index[size];
|
||||||
size_t copySize = (std::min)(size, m_size);
|
size_t copySize = (std::min)(size, m_size);
|
||||||
// copy
|
// copy
|
||||||
internal::smart_copy(m_values, m_values+copySize, newValues);
|
if (copySize>0) {
|
||||||
internal::smart_copy(m_indices, m_indices+copySize, newIndices);
|
internal::smart_copy(m_values, m_values+copySize, newValues);
|
||||||
|
internal::smart_copy(m_indices, m_indices+copySize, newIndices);
|
||||||
|
}
|
||||||
// delete old stuff
|
// delete old stuff
|
||||||
delete[] m_values;
|
delete[] m_values;
|
||||||
delete[] m_indices;
|
delete[] m_indices;
|
||||||
|
|||||||
Reference in New Issue
Block a user