From 9343affe0bf90110a494134a8076c4060d41bbd5 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Thu, 27 Aug 2026 14:53:39 +0800 Subject: [PATCH] fix: check the frame QueryInterface result in dxgi capture Both AcquireNextFrame paths cast the IDXGIResource to ID3D11Texture2D without looking at the HRESULT. ohgodwhat() then dereferences the null pointer in GetDesc(), and get_texture() hands a null texture to the vram encoder. Return the error instead. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_011sw75MSAz7PTqrSALdStXe --- libs/scrap/src/dxgi/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/scrap/src/dxgi/mod.rs b/libs/scrap/src/dxgi/mod.rs index ad731c57c..7fee04642 100644 --- a/libs/scrap/src/dxgi/mod.rs +++ b/libs/scrap/src/dxgi/mod.rs @@ -357,10 +357,10 @@ impl Capturer { // copy from GPU memory to system memory unsafe fn ohgodwhat(&mut self, frame: *mut IDXGIResource) -> io::Result<()> { let mut texture: *mut ID3D11Texture2D = ptr::null_mut(); - (*frame).QueryInterface( + wrap_hresult((*frame).QueryInterface( &IID_ID3D11Texture2D, &mut texture as *mut *mut _ as *mut *mut _, - ); + ))?; let texture = ComPtr(texture); #[allow(invalid_value)] @@ -500,10 +500,10 @@ impl Capturer { } let mut texture: *mut ID3D11Texture2D = ptr::null_mut(); - (*frame.0).QueryInterface( + wrap_hresult((*frame.0).QueryInterface( &IID_ID3D11Texture2D, &mut texture as *mut *mut _ as *mut *mut _, - ); + ))?; let texture = ComPtr(texture); self.texture = texture;