Better sanity check handling WordITerator
Better sanity check handling WordITerator
diff --git a/src/library/IndexDocumentBundle.php b/src/library/IndexDocumentBundle.php
index 9caa36b9b..3d1ddf5fa 100644
--- a/src/library/IndexDocumentBundle.php
+++ b/src/library/IndexDocumentBundle.php
@@ -1475,7 +1475,7 @@ class IndexDocumentBundle implements CrawlConstants
crawlLog("..Length posting string: " .
strlen($postings_string));
crawlLog("..Current position: " . $current_pos);
- break;
+ return []; // sanity check 1
}
$int_info = ord($postings_string[$current_pos]);
$current_pos++;
@@ -1487,7 +1487,7 @@ class IndexDocumentBundle implements CrawlConstants
crawlLog("..Length posting string: " .
strlen($postings_string));
crawlLog("..Current position: " . $current_pos);
- break; //sanity check break
+ return []; // sanity check 2
}
$pre_item = unpack($unpack_map[$int_info], $postings_string,
$current_pos);
diff --git a/src/library/index_bundle_iterators/WordIterator.php b/src/library/index_bundle_iterators/WordIterator.php
index 7ddac6aa9..206d90661 100644
--- a/src/library/index_bundle_iterators/WordIterator.php
+++ b/src/library/index_bundle_iterators/WordIterator.php
@@ -989,10 +989,12 @@ class WordIterator extends IndexBundleIterator
$generation_info['POSTINGS_LEN']);
}
}
- if (empty($postings_entry)) {
- $postings = [];
- } else {
- list($postings,) = $index->unpackPostings($postings_entry);
+ $postings = [];
+ if (!empty($postings_entry)) {
+ $postings_info = $index->unpackPostings($postings_entry);
+ if (!empty($postings_info)) {
+ list($postings,) = $index->unpackPostings($postings_entry);
+ }
}
$this->dictionary_info[$generation]['POSTINGS'] = $postings;
return $postings;