Skip to content

Commit daa5f73

Browse files
committed
[C++] Fix Segfault in SparseCSFIndex::Equals with mismatched dimensions
1 parent 222fac7 commit daa5f73

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

cpp/src/arrow/sparse_tensor.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ SparseCSFIndex::SparseCSFIndex(const std::vector<std::shared_ptr<Tensor>>& indpt
405405
std::string SparseCSFIndex::ToString() const { return std::string("SparseCSFIndex"); }
406406

407407
bool SparseCSFIndex::Equals(const SparseCSFIndex& other) const {
408+
if (indices().size() != other.indices().size() || indptr().size() != other.indptr().size()) {
409+
return false;
410+
}
408411
for (int64_t i = 0; i < static_cast<int64_t>(indices().size()); ++i) {
409412
if (!indices()[i]->Equals(*other.indices()[i])) return false;
410413
}

0 commit comments

Comments
 (0)