File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -43,10 +43,10 @@ int AdjacentCellFinder::in_row_with_margin(int index) const
43
43
44
44
int AdjacentCellFinder::right (int index) const
45
45
{
46
- int next = index+1 ;
47
- if (next >= (int )_positions.size ())
46
+ if (index < 0 || index >= (int )_positions.size () - 1 )
48
47
return -1 ;
49
- if (_positions[next].first < _positions[index].first ) // loop
48
+ int next = index + 1 ;
49
+ if (_positions[next].first < _positions[index].first )
50
50
return -1 ;
51
51
return next;
52
52
}
@@ -63,16 +63,17 @@ int AdjacentCellFinder::left(int index) const
63
63
64
64
int AdjacentCellFinder::bottom (int index) const
65
65
{
66
+ if (index < 0 || index >= (int )_positions.size ())
67
+ return -1 ;
66
68
int increment = _dimensions;
67
69
if (in_row_with_margin (index))
68
70
increment -= _markerSize;
69
71
int next = index + increment;
70
72
if (in_row_with_margin (next))
71
73
next -= _markerSize;
72
-
73
- if (next >= (int )_positions.size ())
74
+ if (next < 0 || next >= (int )_positions.size ())
74
75
return -1 ;
75
- if (_positions[next].first != _positions[index].first ) // near anchor
76
+ if (_positions[next].first != _positions[index].first )
76
77
return -1 ;
77
78
return next;
78
79
}
You can’t perform that action at this time.
0 commit comments