Auto merge of #7279 - pcwalton:tile-image-divide-by-zero, r=mbrubeck

layout: Avoid a division by zero in `tile_image()`.

Fixes a crash on Facebook Timeline.

r? @mbrubeck

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7279)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-08-19 04:41:54 -06:00
commit 0234bbe444
4 changed files with 19 additions and 2 deletions

View file

@ -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);