Better sanity check handling WordITerator, position list decode
Better sanity check handling WordITerator, position list decode
diff --git a/src/library/index_bundle_iterators/WordIterator.php b/src/library/index_bundle_iterators/WordIterator.php
index 81a710799..6a9bbb5cb 100644
--- a/src/library/index_bundle_iterators/WordIterator.php
+++ b/src/library/index_bundle_iterators/WordIterator.php
@@ -497,10 +497,13 @@ class WordIterator extends IndexBundleIterator
foreach ($postings as $posting) {
$posting[self::GENERATION] = $partition;
if ($posting['POSITIONS_LEN'] > 0 && !empty($fh)) {
- fseek($fh, $posting['POSITIONS_OFFSET']);
- $encoded_positions = fread($fh, $posting['POSITIONS_LEN']);
- $posting[self::POSITION_LIST] = L\decodePositionList(
- $encoded_positions, $posting['FREQUENCY']);
+ if (fseek($fh, $posting['POSITIONS_OFFSET']) >= 0) {
+ $encoded_positions = fread($fh, $posting['POSITIONS_LEN']);
+ $posting[self::POSITION_LIST] = L\decodePositionList(
+ $encoded_positions, $posting['FREQUENCY']);
+ } else {
+ $posting[self::POSITION_LIST] = [];
+ }
} else {
$posting[self::POSITION_LIST] = [];
}