Skip to content

Commit

Permalink
bugfix for keyword field truncate
Browse files Browse the repository at this point in the history
  • Loading branch information
unix1986 authored and jtong11 committed Oct 9, 2020
1 parent 8e5d29d commit 7a09834
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/core/doc/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ impl Field {
Some(VariantValue::Binary(bytes))
}
VariantValue::VString(vs) => {
let s = (&vs[..(ByteBlockPool::BYTE_BLOCK_SIZE - 2).min(vs.len())]).to_string();
let mut index = (ByteBlockPool::BYTE_BLOCK_SIZE - 2).min(vs.len());
while !vs.is_char_boundary(index) {
index -= 1;
}
let s = (&vs[..index]).to_string();
Some(VariantValue::VString(s))
}
_ => Some(data),
Expand Down
2 changes: 1 addition & 1 deletion src/core/util/bytes_ref_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl BytesRefHash {
// new entry
let len2 = 2 + bytes.len();
if len2 + self.byte_pool().byte_upto > ByteBlockPool::BYTE_BLOCK_SIZE {
assert!(len2 < ByteBlockPool::BYTE_BLOCK_SIZE);
assert!(len2 <= ByteBlockPool::BYTE_BLOCK_SIZE);
// this length check already done in the caller func
// if len2 > BYTE_BLOCK_SIZE {
// bail!("bytes can be at most: {}, got: {}", BYTE_BLOCK_SIZE -
Expand Down

0 comments on commit 7a09834

Please sign in to comment.