diff options
author | Federico Mena Quintero <federico@gnome.org> | 2023-01-24 13:24:34 -0600 |
---|---|---|
committer | Federico Mena Quintero <federico@gnome.org> | 2023-01-24 13:26:44 -0600 |
commit | 3a5d25b88662143007ac7143ddcb69a4be57ee3e (patch) | |
tree | cc9cc59023a5a9225b927481b949ecc932a45a7b | |
parent | 7a682574f19d9a7f4d7fcd876c8383a1fa203f04 (diff) | |
download | librsvg-3a5d25b88662143007ac7143ddcb69a4be57ee3e.tar.gz |
SharedSurface::tile() - Don't allow empty subregions
This is intended to panic earlier than SharedImageSurface::wrap(), for clarity.
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/787>
-rw-r--r-- | src/surface_utils/shared_surface.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/surface_utils/shared_surface.rs b/src/surface_utils/shared_surface.rs index 0bd74353..4fdd66c2 100644 --- a/src/surface_utils/shared_surface.rs +++ b/src/surface_utils/shared_surface.rs @@ -1079,8 +1079,16 @@ impl ImageSurface<Shared> { } /// Creates a new surface with the size and content specified in `bounds` + /// + /// # Panics + /// Panics if `bounds` is an empty rectangle, since `SharedImageSurface` cannot + /// represent zero-sized images. #[inline] pub fn tile(&self, bounds: IRect) -> Result<SharedImageSurface, cairo::Error> { + // Cairo lets us create zero-sized surfaces, but the call to SharedImageSurface::wrap() + // below will panic in that case. So, disallow requesting a zero-sized subregion. + assert!(!bounds.is_empty()); + let output_surface = cairo::ImageSurface::create(cairo::Format::ARgb32, bounds.width(), bounds.height())?; |