zed-industries/zed · error
pathbuf should not be nul terminated
Error message
pathbuf should not be nul terminated
What it means
In the Linux save-file dialog path, the suggested file name is converted with CString-like handling; the expect asserts the pathbuf/name contains no interior NUL bytes. A path containing '\0' cannot be passed to the file chooser portal, so the request panics instead of silently truncating.
Source
Thrown at crates/gpui_linux/src/linux/platform.rs:542
let _ = (done_tx.send(Ok(None)), directory, suggested_name);
#[cfg(any(feature = "wayland", feature = "x11"))]
let identifier = self.inner.window_identifier();
#[cfg(any(feature = "wayland", feature = "x11"))]
self.foreground_executor()
.spawn({
let directory = directory.to_owned();
let suggested_name = suggested_name.map(|s| s.to_owned());
async move {
let mut request_builder =
ashpd::desktop::file_chooser::SaveFileRequest::default()
.identifier(identifier.await)
.modal(true)
.title("Save File")
.current_folder(directory)
.expect("pathbuf should not be nul terminated");
if let Some(suggested_name) = suggested_name {
request_builder = request_builder.current_name(suggested_name.as_str());
}
let request = match request_builder.send().await {
Ok(request) => request,
Err(err) => {
let result = match err {
ashpd::Error::PortalNotFound(_) => {
anyhow!(FILE_PICKER_PORTAL_MISSING)
}
err => err.into(),
};
let _ = done_tx.send(Err(result));
return;
}
};View on GitHub (pinned to 9d272b0363)
Solutions
- Sanitize suggested names/directories, rejecting or stripping NUL bytes before the dialog
- Return a user-visible error for invalid paths instead of panicking
- Check where the suggested name originates (remote data may embed NULs)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/gpui_linux/src/linux/platform.rs:487 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20).
Data as JSON: /api/errors/8483d1e97a9cd906.
Report an issue: GitHub.