We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b1bc851 commit cbc15b8Copy full SHA for cbc15b8
cairo/src/image_surface.rs
@@ -64,7 +64,12 @@ impl ImageSurface {
64
(data.as_mut_ptr(), data.len())
65
};
66
67
- assert!(len >= (height * stride) as usize);
+ assert!(width >= 0, "width must be non-negative");
68
+ assert!(height >= 0, "height must be non-negative");
69
+ assert!(stride >= 0, "stride must be non-negative");
70
+
71
+ // check if there is integer overflow
72
+ assert!(len >= height.checked_mul(stride).unwrap() as usize);
73
let result = unsafe {
74
ImageSurface::from_raw_full(ffi::cairo_image_surface_create_for_data(
75
ptr,
0 commit comments