Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
file_content: Fix stack overflow in encoding detection (#65102)
tidely199500e9be91
diff --git a/crates/file_content/src/file_content.rs b/crates/file_content/src/file_content.rsindex b978f4aa40e..785611f2efc 100644--- a/crates/file_content/src/file_content.rs+++ b/crates/file_content/src/file_content.rs@@ -88,7 +88,7 @@ pub fn decode_text(bytes: Vec<u8>) -> Result<DecodedText> {pub async fn detect_encoding(reader: &mut (dyn Read + Send)) -> io::Result<&'static Encoding> {let mut detector = EncodingDetector::new();- let mut block = [0; DECODING_BLOCK_BYTES];+ let mut block = vec![0; DECODING_BLOCK_BYTES];let mut length = 0;loop {let read = match reader.read(&mut block[length..]) {