Bug 1362115 - properly handle empty slices in FFI bindings. r?kats draft
authorAlexis Beingessner <a.beingessner@gmail.com>
Mon, 05 Feb 2018 12:41:11 -0500
changeset 751191 8f746f3cb53b33a01f04899df32b5560ed1bbb21
parent 751190 6b852377e0df2aecd93326f27891dd70d9873a0f
child 751192 0a5b060673ea664f98992bb721a9b17d29ed6695
child 751271 457f4b05cf8836d5ef45eb0da1f2a08596eae49c
push id97890
push userbmo:a.beingessner@gmail.com
push dateMon, 05 Feb 2018 17:43:50 +0000
reviewerskats
bugs1362115
milestone60.0a1
Bug 1362115 - properly handle empty slices in FFI bindings. r?kats MozReview-Commit-ID: 9Zw0RTbgsBL
gfx/webrender_bindings/src/bindings.rs
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -173,17 +173,17 @@ pub extern "C" fn wr_vec_u8_free(v: WrVe
 pub struct ByteSlice {
     buffer: *const u8,
     len: usize,
 }
 
 impl ByteSlice {
     pub fn new(slice: &[u8]) -> ByteSlice {
         ByteSlice {
-            buffer: &slice[0],
+            buffer: slice.as_ptr(),
             len: slice.len(),
         }
     }
 
     pub fn as_slice(&self) -> &[u8] {
         make_slice(self.buffer, self.len)
     }
 }
@@ -193,17 +193,17 @@ pub struct MutByteSlice {
     buffer: *mut u8,
     len: usize,
 }
 
 impl MutByteSlice {
     pub fn new(slice: &mut [u8]) -> MutByteSlice {
         let len = slice.len();
         MutByteSlice {
-            buffer: &mut slice[0],
+            buffer: slice.as_mut_ptr(),
             len: len,
         }
     }
 
     pub fn as_mut_slice(&mut self) -> &mut [u8] {
         make_slice_mut(self.buffer, self.len)
     }
 }