Bug 1359462 - Don't create a slice using a null pointer when convering the list of WrComplexClipRegion to ComplexClipRegion. r?rhunt draft
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 25 Apr 2017 13:44:06 -0400
changeset 568043 3a20e5e13a55e6c12fb1fbf799ab61d3a0154df3
parent 568042 ace499d0417aa372ffdceabde3d91ca81015fff8
child 625801 8f9eb136d39bd1442de837a1b62d4bac7ab685b6
push id55736
push userkgupta@mozilla.com
push dateTue, 25 Apr 2017 17:44:20 +0000
reviewersrhunt
bugs1359462
milestone55.0a1
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
gfx/webrender_bindings/src/bindings.rs
--- 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]