diff options
Diffstat (limited to 'src/bytes.rs')
-rw-r--r-- | src/bytes.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/bytes.rs b/src/bytes.rs index f8421ef..08ae3c7 100644 --- a/src/bytes.rs +++ b/src/bytes.rs @@ -709,6 +709,13 @@ impl From<&'static str> for Bytes { impl From<Vec<u8>> for Bytes { fn from(vec: Vec<u8>) -> Bytes { + // into_boxed_slice doesn't return a heap allocation for empty vectors, + // so the pointer isn't aligned enough for the KIND_VEC stashing to + // work. + if vec.is_empty() { + return Bytes::new(); + } + let slice = vec.into_boxed_slice(); let len = slice.len(); let ptr = slice.as_ptr(); |