mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-19 06:59:22 +01:00
file_content: Fix stack overflow in encoding detection (#65102)
## Summary Fix a stack overflow when searching a project in a macOS debug build. When on a debug build, opening a project which hits the `detect_encoding` code path and typing in a global search triggers an illegal instruction violation. The regression was introduced in #64549 Allocate the encoding detector’s 64 KiB buffer using a `Vec`. The inline array enlarged nested search futures and their debug-build stack frames beyond the background worker’s available stack. This hasn't hit stable yet, so I've omitted a release note. ## Testing - All tests pass - Change is extremely trivial - Project search no longer crashes with this patch To verify manually on macOS, launch Zed with `cargo run`, open a Rust project, press Cmd-Shift-F, and search for anything. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [[checklist](https://zed.dev/docs/development/ui-checklist)](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - N/A
This commit is contained in:
@@ -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..]) {
|
||||
|
||||
Reference in New Issue
Block a user