AliRana30 opened a new issue, #49104:
URL: https://github.com/apache/arrow/issues/49104
### Describe the bug, including details regarding any error messages,
version, and platform.
## **Describe the Bug**
`SparseCSFIndex::Equals` causes a segmentation fault when comparing two
`SparseCSFIndex` objects that have a different number of dimensions. The method
iterates through the `indices()` and `indptr()` vectors based on the size of
the current object but does not verify that the `other` object has matching
vector sizes, leading to out-of-bounds access and a crash.
File: `cpp/src/arrow/sparse_tensor.cc`
```cpp
bool SparseCSFIndex::Equals(const SparseCSFIndex& other) const {
for (int64_t i = 0; i < static_cast<int64_t>(indices().size()); ++i) {
if (!indices()[i]->Equals(*other.indices()[i])) return false; // ❌
Segfault if other.indices() is smaller
}
for (int64_t i = 0; i < static_cast<int64_t>(indptr().size()); ++i) {
if (!indptr()[i]->Equals(*other.indptr()[i])) return false; // ❌
Segfault if other.indptr() is smaller
}
return axis_order() == other.axis_order();
}
```
**Component(s)**
C++
### Component(s)
C++
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]