Commit e37c516
### Rationale for This Change
The `SparseCSFIndex::Equals` method can crash when comparing two sparse indices that have a different number of dimensions. The method iterates over the `indices()` and `indptr()` vectors of the current object and accesses the corresponding elements in the `other` object without first verifying that both objects have matching vector sizes. This can lead to out-of-bounds access and a segmentation fault when the dimension counts differ.
### What Changes Are Included in This PR?
This change adds explicit size equality checks for the `indices()` and `indptr()` vectors at the beginning of the `SparseCSFIndex::Equals` method. If the dimensions do not match, the method now safely returns `false` instead of attempting invalid memory access.
### Are These Changes Tested?
Yes. The fix has been validated through targeted reproduction of the crash scenario using mismatched dimension counts, ensuring the method behaves safely and deterministically.
### Are There Any User-Facing Changes?
No. This change improves internal safety and robustness without altering public APIs or observable user behavior.
* GitHub Issue: #49104
Lead-authored-by: Alirana2829 <alimahmoodrana00@gmail.com>
Co-authored-by: Ali Mahmood Rana <159713825+AliRana30@users.noreply.github.com>
Co-authored-by: Rok Mihevc <rok@mihevc.org>
Signed-off-by: Rok Mihevc <rok@mihevc.org>
1 parent 33f1ea5 commit e37c516
2 files changed
Lines changed: 27 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
415 | 412 | | |
416 | 413 | | |
417 | 414 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1641 | 1641 | | |
1642 | 1642 | | |
1643 | 1643 | | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
1644 | 1666 | | |
1645 | 1667 | | |
1646 | 1668 | | |
1647 | | - | |
| 1669 | + | |
1648 | 1670 | | |
1649 | 1671 | | |
1650 | 1672 | | |
| |||
0 commit comments