Transform from clipPath and mask needs to be validated
Both code paths for clipPath and mask need to validate the transform
property before applying it to the cr
.
From DrawingCtx::clip_to_node():
let node = clip_node.as_ref().unwrap();
let units = borrow_element_as!(node, ClipPath).get_units();
if let Ok(transform) = rect_to_transform(&bbox.rect, units) {
let cascaded = CascadedValues::new_from_node(node);
let values = cascaded.get();
let node_transform = values.transform().post_transform(&transform);
let orig_transform = self.get_transform();
self.cr.transform(node_transform.into());
// ^^^^^^^^^^^^^^ This needs to be validated
From DrawingCtx::generate_cairo_mask():
let mask_transform = values.transform().post_transform(&transform);
let mask_content_surface = self.create_surface_for_toplevel_viewport()?;
// Use a scope because mask_cr needs to release the
// reference to the surface before we access the pixels
{
let mask_cr = cairo::Context::new(&mask_content_surface)?;
mask_cr.set_matrix(mask_transform.into());
// ^^^^^^^^^^^^^^ This needs to be validated
Right now Cairo catches the error and we catch it somewhere later, but this should be validated before it has a chance to get to Cairo.
It would be a good idea to look at all calls to cr.transform()
and cr.set_matrix()
to see if there are others in the same situation.