fix(portal): reject frames before format negotiation to prevent zero-dimension encoder init

This commit is contained in:
dailz
2026-05-22 15:17:14 +08:00
parent 13ca010ecc
commit b9e62d6830

View File

@@ -326,15 +326,21 @@ fn pipewire_thread(ctx: PwThreadCtx) {
pts_val
};
let Some((width, height, format, modifier)) = format_info.get() else {
unsafe { stream.queue_raw_buffer(raw_buf) };
return;
};
if width == 0 || height == 0 || format == 0 {
unsafe { stream.queue_raw_buffer(raw_buf) };
return;
}
let dup_fd = unsafe { libc::dup(fd) };
if dup_fd < 0 {
unsafe { stream.queue_raw_buffer(raw_buf) };
return;
}
let (width, height, format, modifier) =
format_info.get().unwrap_or((0, 0, 0, 0));
let frame = PwDmaBufFrame {
fd: unsafe { OwnedFd::from_raw_fd(dup_fd) },
offset,