mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-05 19:46:07 +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:
parent
e4ed2566d5
commit
8d4d85161e
@ -208,8 +208,10 @@ class CompressedStorage
|
||||
Index* newIndices = new Index[size];
|
||||
size_t copySize = (std::min)(size, m_size);
|
||||
// copy
|
||||
internal::smart_copy(m_values, m_values+copySize, newValues);
|
||||
internal::smart_copy(m_indices, m_indices+copySize, newIndices);
|
||||
if (copySize>0) {
|
||||
internal::smart_copy(m_values, m_values+copySize, newValues);
|
||||
internal::smart_copy(m_indices, m_indices+copySize, newIndices);
|
||||
}
|
||||
// delete old stuff
|
||||
delete[] m_values;
|
||||
delete[] m_indices;
|
||||
|
Loading…
x
Reference in New Issue
Block a user