Bug 1359462 - Don't create a slice using a null pointer when convering the list of WrComplexClipRegion to ComplexClipRegion. r?rhunt
MozReview-Commit-ID: 4szHWhwHqtC
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -1220,18 +1220,21 @@ pub extern "C" fn wr_dp_new_clip_region(
main: WrRect,
complex: *const WrComplexClipRegion,
complex_count: usize,
image_mask: *const WrImageMask)
-> WrClipRegion {
assert!(unsafe { is_in_main_thread() });
let main = main.into();
- let complex_slice = make_slice(complex, complex_count);
- let complex_vector = complex_slice.iter().map(|x| x.into()).collect();
+ let complex_vector = if complex.is_null() {
+ Vec::<ComplexClipRegion>::new()
+ } else {
+ make_slice(complex, complex_count).iter().map(|x| x.into()).collect()
+ };
let mask = unsafe { image_mask.as_ref() }.map(|x| x.into());
let clip_region = state.frame_builder.dl_builder.new_clip_region(&main, complex_vector, mask);
clip_region.into()
}
#[no_mangle]