Bug 1279348: Avoid division by 0. r=kentuckyfriedtakahe
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 14 Sep 2016 11:20:41 +1000
changeset 357645 cdab1a072387f67420d5bc90a4993c89ac6b9d73
parent 357644 d8a383370502b41992775dc4efc2501453c14170
child 357646 0554a9b821e6333bac8d0785fd25ef2381aff094
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe
bugs1279348
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1279348: Avoid division by 0. r=kentuckyfriedtakahe MozReview-Commit-ID: DSwB3J9jADK
dom/media/MediaInfo.h
--- a/dom/media/MediaInfo.h
+++ b/dom/media/MediaInfo.h
@@ -256,17 +256,18 @@ public:
   // If aWidth and aHeight are identical to the original mImage.width/mImage.height
   // then the scaling ratio will be 1.
   // This is used for when the frame size is different from what the container
   // reports. This is legal in WebM, and we will preserve the ratio of the crop
   // rectangle as it was reported relative to the picture size reported by the
   // container.
   nsIntRect ScaledImageRect(int64_t aWidth, int64_t aHeight) const
   {
-    if (aWidth == mImage.width && aHeight == mImage.height) {
+    if ((aWidth == mImage.width && aHeight == mImage.height) ||
+        !mImage.width || !mImage.height) {
       return ImageRect();
     }
     nsIntRect imageRect = ImageRect();
     imageRect.x = (imageRect.x * aWidth) / mImage.width;
     imageRect.y = (imageRect.y * aHeight) / mImage.height;
     imageRect.width = (aWidth * imageRect.width) / mImage.width;
     imageRect.height = (aHeight * imageRect.height) / mImage.height;
     return imageRect;