mirror of
https://github.com/Devolutions/IronRDP.git
synced 2026-11-23 00:14:10 +00:00
fix(egfx): drop a surface's previous canvas when its re-creation is refused
A surface created again past the edge limit kept the canvas of the one before it, so has_surface answered yes and its Progressive updates were decoded.
This commit is contained in:
@@ -3616,6 +3616,30 @@ mod tests {
|
||||
assert!(updates.lock().unwrap().is_empty());
|
||||
}
|
||||
|
||||
/// Creating a surface again past the compositor's edge limit refuses it, even though the previous one fit.
|
||||
// oracle: mutant keeping a surface's previous canvas when its re-creation is past the edge limit
|
||||
#[test]
|
||||
fn surface_recreated_past_the_edge_limit_does_not_decode_progressive() {
|
||||
let updates = Arc::new(Mutex::new(Vec::new()));
|
||||
let mut client = progressive_client();
|
||||
// 20000 is past the compositor's 16384-pixel edge limit.
|
||||
client
|
||||
.handle_pdu(GfxPdu::CreateSurface(crate::pdu::CreateSurfacePdu {
|
||||
surface_id: 1,
|
||||
width: 20000,
|
||||
height: 64,
|
||||
pixel_format: PixelFormat::XRgb,
|
||||
}))
|
||||
.unwrap();
|
||||
client.handler = Box::new(CapturingHandler {
|
||||
updates: Arc::clone(&updates),
|
||||
unhandled: Arc::new(Mutex::new(0)),
|
||||
});
|
||||
assert!(wire_progressive(&mut client, progressive_tile_stream(0, 0, rect(0, 0, 64, 64), 0)).is_ok());
|
||||
assert_eq!(client.dropped_updates(), 0);
|
||||
assert!(updates.lock().unwrap().is_empty());
|
||||
}
|
||||
|
||||
/// An update a refused surface skips changes tiles the decoder no longer tracks.
|
||||
/// A difference tile sent once the surface is accepted again has no reference.
|
||||
// oracle: mutant skipping a refused surface's update without discarding its earlier tile state
|
||||
|
||||
@@ -357,17 +357,18 @@ impl Compositor {
|
||||
/// allocated; subsequent commands targeting them become no-ops (the metadata
|
||||
/// tracked by the client is unaffected).
|
||||
pub(crate) fn create_surface(&mut self, id: u16, width: u16, height: u16) {
|
||||
// Release first: `BTreeMap::insert` drops any surface already under this id,
|
||||
// so re-creating one must not charge twice for the same slot.
|
||||
// A refused re-creation also drops the previous canvas, so its commands become no-ops.
|
||||
if let Some(previous) = self.surfaces.remove(&id) {
|
||||
self.release(previous.data.len());
|
||||
}
|
||||
|
||||
if width == 0 || height == 0 || width > MAX_SURFACE_DIM || height > MAX_SURFACE_DIM {
|
||||
return;
|
||||
}
|
||||
let len = usize::from(width) * usize::from(height) * BYTES_PER_PIXEL;
|
||||
|
||||
// Release first: `BTreeMap::insert` drops any surface already under this id,
|
||||
// so re-creating one must not charge twice for the same slot.
|
||||
if let Some(previous) = self.surfaces.remove(&id) {
|
||||
self.release(previous.data.len());
|
||||
}
|
||||
|
||||
if !self.charge(len) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user