Skip to content

Commit

Permalink
style: Avoid writing into the empty array header.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Dec 16, 2019
1 parent f89c311 commit 80ac4d2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions components/style/gecko_bindings/sugar/ns_t_array.rs
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 80ac4d2

Please sign in to comment.