diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2015-08-18 18:41:55 -0700 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2015-08-18 18:44:50 -0700 |
commit | 02b15e016d7adb89c9142e9e89a7048c15d9c085 (patch) | |
tree | eb83a72f980ac3279d85fff7d1fc2153549b3d7a /components | |
parent | 19d466b06250f10169e88fc7f0b447c7f2f8209e (diff) | |
download | servo-02b15e016d7adb89c9142e9e89a7048c15d9c085.tar.gz servo-02b15e016d7adb89c9142e9e89a7048c15d9c085.zip |
layout: Avoid a division by zero in `tile_image()`.
Fixes a crash on Facebook Timeline.
Diffstat (limited to 'components')
-rw-r--r-- | components/layout/fragment.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 568ebf50657..68dde96f3fb 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -390,9 +390,13 @@ impl ImageFragmentInfo { } /// Tile an image - pub fn tile_image(position: &mut Au, size: &mut Au, - virtual_position: Au, image_size: u32) { + pub fn tile_image(position: &mut Au, size: &mut Au, virtual_position: Au, image_size: u32) { + // Avoid division by zero below! let image_size = image_size as i32; + if image_size == 0 { + return + } + let delta_pixels = (virtual_position - *position).to_px(); let tile_count = (delta_pixels + image_size - 1) / image_size; let offset = Au::from_px(image_size * tile_count); |