Skip to content
Permalink
Browse files

style: Avoid writing into the empty array header.

  • Loading branch information
emilio committed Dec 16, 2019
1 parent f89c311 commit 80ac4d2ff28b093fd3730cde7280b01577539f8f
Showing with 7 additions and 2 deletions.
  1. +7 −2 components/style/gecko_bindings/sugar/ns_t_array.rs
@@ -89,9 +89,11 @@ impl<T> nsTArray<T> {
pub unsafe fn set_len(&mut self, len: u32) {
// this can leak
debug_assert!(len >= self.len() as u32);
if self.len() == len as usize {
return;
}
self.ensure_capacity(len as usize);
let header = self.header_mut();
header.mLength = len;
self.header_mut().mLength = len;
}

/// Resizes an array containing only POD elements
@@ -103,6 +105,9 @@ impl<T> nsTArray<T> {
where
T: Copy,
{
if self.len() == len as usize {
return;
}
self.ensure_capacity(len as usize);
let header = self.header_mut();
header.mLength = len;

0 comments on commit 80ac4d2

Please sign in to comment.
You can’t perform that action at this time.