Bug 1228314 - added static_cast<int64> in order to avoid overflow. r?seth draft
authorBogdan Postelnicu <bogdan.postelnicu@softvision.ro>
Mon, 18 Jan 2016 17:23:23 +0200
changeset 334863 a62e5d2cd8a93bafc41e4ec0ecb89b6a780a7e8e
parent 334552 c1e0d1890cfee9d86c8d566b0490053f21e0afc6
child 515010 873f60a3a462f13cf14b14dce5b151dbf4090f48
push id11653
push userBogdan.Postelnicu@softvision.ro
push dateFri, 26 Feb 2016 08:42:46 +0000
reviewersseth
bugs1228314
milestone47.0a1
Bug 1228314 - added static_cast<int64> in order to avoid overflow. r?seth MozReview-Commit-ID: KY3qpIlzE5K
image/SurfaceCache.cpp
--- a/image/SurfaceCache.cpp
+++ b/image/SurfaceCache.cpp
@@ -322,17 +322,18 @@ public:
         continue;
       }
 
       SurfaceKey bestMatchKey = bestMatch->GetSurfaceKey();
 
       // Compare sizes. We use an area-based heuristic here instead of computing a
       // truly optimal answer, since it seems very unlikely to make a difference
       // for realistic sizes.
-      int64_t idealArea = idealKey.Size().width * idealKey.Size().height;
+      int64_t idealArea = static_cast<int64_t>(idealKey.Size().width) *
+        static_cast<int64_t>(idealKey.Size().height);
       int64_t surfaceArea = aSurfaceKey.Size().width * aSurfaceKey.Size().height;
       int64_t bestMatchArea =
         bestMatchKey.Size().width * bestMatchKey.Size().height;
 
       // If the best match is smaller than the ideal size, prefer bigger sizes.
       if (bestMatchArea < idealArea) {
         if (surfaceArea > bestMatchArea) {
           bestMatch = surface;