Skip to content

Commit 483cf33

Browse files
authored
Fix address sanitizer issue (#323)
Worked this with @cketcham2333 ... Prior to this change, if I compile `test_core` with address sanitization support, I got these errors below. And after this PR, these errors go away. It's unclear if these errors would impact us under normal conditions or not because normally `Scalar` is a primitive type that does not have a destructor.
1 parent e202ed2 commit 483cf33

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libs/core/lib/tensor_impls/xtensor_impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class xtensor : public cudaqx::details::tensor_impl<Scalar> {
9797
auto size = std::accumulate(shape.begin(), shape.end(), 1,
9898
std::multiplies<size_t>());
9999
if (m_data)
100-
std::free(m_data);
100+
delete[] m_data;
101101

102102
m_data = new Scalar[size];
103103
std::copy(d, d + size, m_data);
@@ -306,7 +306,7 @@ class xtensor : public cudaqx::details::tensor_impl<Scalar> {
306306
/// @brief Destructor for xtensor
307307
~xtensor() {
308308
if (ownsData)
309-
delete m_data;
309+
delete[] m_data;
310310
}
311311
};
312312

0 commit comments

Comments
 (0)