{"record":{"id":"5735c8894686a942","repo":"rustdesk/rustdesk","slug":"invalid-mask-cursor-buffer-size-got-bytes-exp","errorCode":null,"errorMessage":"Invalid mask cursor buffer size, got {} bytes, expected {}","messagePattern":"Invalid mask cursor buffer size, got (.+?) bytes, expected (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/platform/windows.rs","lineNumber":285,"sourceCode":"        let mut height = if ii.is_color() {\n            bm_mask.bmHeight\n        } else {\n            bm_mask.bmHeight / 2\n        };\n        let cbits_size = width * height * 4;\n        if cbits_size < 16 {\n            bail!(\"Invalid icon: too small\"); // solve some crash\n        }\n        let mut cbits: Vec<u8> = Vec::new();\n        cbits.resize(cbits_size as _, 0);\n        let mut mbits: Vec<u8> = Vec::new();\n        mbits.resize((bm_mask.bmWidthBytes * bm_mask.bmHeight) as _, 0);\n        let r = GetBitmapBits(ii.0.hbmMask, mbits.len() as _, mbits.as_mut_ptr() as _);\n        if r == 0 {\n            bail!(\"Failed to copy bitmap data\");\n        }\n        if r != (mbits.len() as i32) {\n            bail!(\n                \"Invalid mask cursor buffer size, got {} bytes, expected {}\",\n                r,\n                mbits.len()\n            );\n        }\n        let do_outline;\n        if ii.is_color() {\n            get_rich_cursor_data(ii.0.hbmColor, width, height, &mut cbits)?;\n            do_outline = fix_cursor_mask(\n                &mut mbits,\n                &mut cbits,\n                width as _,\n                height as _,\n                bm_mask.bmWidthBytes as _,\n            );\n        } else {\n            do_outline = handleMask(\n                cbits.as_mut_ptr(),","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/rustdesk/rustdesk/blob/91c9fccbb0f7bfe5f11644d5fbdec9b23fa10540/src/platform/windows.rs#L267-L303","documentation":"Post-copy sanity check: the number of mask bytes actually retrieved does not match the expected bmWidthBytes × bmHeight buffer size. This indicates the OS delivered a different mask layout than the BITMAP header advertised (stale handle or unusual driver), so the buffer is unusable for building valid cursor data.","triggerScenarios":"Thrown at src/platform/windows.rs:285 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Discard this cursor frame and retry capture, since the mismatch usually stems from a cursor being replaced concurrently","Validate the BITMAP header dimensions immediately before the copy and re-query GetObjectA if the cursor handle may be stale","Skip serializing this cursor and keep the previously captured shape"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"91c9fccbb0f7bfe5f11644d5fbdec9b23fa10540","analyzedAt":"2026-09-10T19:53:44.083Z","contentChangedAt":"2026-09-10T19:53:44.083Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}