Skip to content

Commit 17d7ba5

Browse files
authored
Prevent any work if search query offset is outside of document range. (#8378)
1 parent ec19ac0 commit 17d7ba5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/lib/search/mem_index.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ class InMemoryPackageIndex {
122122
}
123123

124124
PackageSearchResult search(ServiceSearchQuery query) {
125+
// prevent any work if offset is outside of the range
126+
if ((query.offset ?? 0) > _documents.length) {
127+
return PackageSearchResult(
128+
timestamp: clock.now(),
129+
totalCount: 0,
130+
packageHits: [],
131+
);
132+
}
125133
return _scorePool.withScore(
126134
value: 1.0,
127135
fn: (score) {

0 commit comments

Comments
 (0)