addDictionary error checking improvements, a=chris
addDictionary error checking improvements, a=chris
diff --git a/src/library/IndexDictionary.php b/src/library/IndexDictionary.php
index 23d4f15ce..dcdecea25 100644
--- a/src/library/IndexDictionary.php
+++ b/src/library/IndexDictionary.php
@@ -228,7 +228,7 @@ class IndexDictionary implements CrawlConstants
$rec_num = ($i << 8) + $j;
$prefix_info = $this->extractPrefixRecord($prefix_string,
$rec_num);
- if ($prefix_info !== false) {
+ if (isset($prefix_info[1])) {
list($offset, $count) = $prefix_info;
if ($first_offset_flag) {
$first_offset = $offset;
diff --git a/src/library/IndexShard.php b/src/library/IndexShard.php
index 655fdd899..6e9d0adcf 100644
--- a/src/library/IndexShard.php
+++ b/src/library/IndexShard.php
@@ -1566,7 +1566,7 @@ class IndexShard extends PersistentStructure implements
* @param int $offset byte offset to start reading from
* @param int $len number of bytes to read
* @param bool $cache whether to cache disk blocks read from disk
- * @return string data fromthat location in the shard
+ * @return string data from that location in the shard
*/
public function getShardSubstring($offset, $len, $cache = true)
{
@@ -1580,13 +1580,17 @@ class IndexShard extends PersistentStructure implements
}
// otherwise, this loop is slower, but handles general case
$data = $this->readBlockShardAtOffset($block_offset, $cache);
- if ($data === false) {return "";}
+ if ($data === false) {
+ return "";
+ }
$substring = substr($data, $start_loc);
$block_size = self::SHARD_BLOCK_SIZE;
$block_offset += $block_size;
while (strlen($substring) < $len) {
$data = $this->readBlockShardAtOffset($block_offset, $cache);
- if ($data === false) {return $substring;}
+ if ($data === false) {
+ return $substring;
+ }
$block_offset += $block_size;
$substring .= $data;
}
diff --git a/src/library/Utility.php b/src/library/Utility.php
index cbaada7ee..8fcb9c66d 100755
--- a/src/library/Utility.php
+++ b/src/library/Utility.php
@@ -230,6 +230,9 @@ function charCopy($source, &$destination, $start, $length, $timeout_msg = "")
$endk = intval($length - 1);
$end = intval($start + $endk);
$start = intval($start);
+ if (strlen($destination) <= $endk) {
+ return;
+ }
if ($timeout_msg == "") {
for ($j = $end, $k = $endk; $j >= $start; $j--, $k--) {
$destination[$j] = $source[$k];