Bug 1279348: Avoid division by 0. r?kentuckyfriedtakahe
MozReview-Commit-ID: DSwB3J9jADK
--- 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;