AliRana30 commented on PR #49105: URL: https://github.com/apache/arrow/pull/49105#issuecomment-3842136372
@raulcd This change fixes a segmentation fault that occurs when comparing `SparseCSFIndex` objects with mismatched dimensions. **Bug description:** The original implementation calls `indices()[i]->Equals(...)` without first verifying that both objects have the same number of dimensions. When comparing, for example, a 2D index with a 3D index: - `indices().size()` returns different values (e.g., 2 vs 3) - The loop iterates using the size of the first object - Accessing `other.indices()[i]` with mismatched sizes results in out-of-bounds access, leading to a segmentation fault **Fix:** Lines 408–416 add early size checks before any iteration: ```cpp if (indices().size() != other.indices().size()) return false; if (indptr().size() != other.indptr().size()) return false; if (axis_order().size() != other.axis_order().size()) return false; ``` These checks ensure that Equals safely returns false when dimensions do not match, preventing access to invalid memory. **Test coverage:** Added TestEqualityMismatchedDimensions (lines 1644–1661), which reproduces theoriginal issue. Without this fix, the test would crash due to the segmentation fault. -- 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]
