Closed Bug 1251742 Opened 9 years ago Closed 9 years ago

avoid overflow in computing area of surface sizes in SurfaceCache

Categories

(Core :: Graphics: ImageLib, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla47
Tracking Status
firefox46 --- fixed
firefox47 --- fixed

People

(Reporter: tnikkel, Assigned: tnikkel)

References

Details

Attachments

(1 file)

      No description provided.
Attached patch patchSplinter Review
This patch is before the patch for bug 1251091 in my patch queue, so I'll land this patch first.
Attachment #8724244 - Flags: review?(dholbert)
Comment on attachment 8724244 [details] [diff] [review]
patch

Review of attachment 8724244 [details] [diff] [review]:
-----------------------------------------------------------------

::: image/SurfaceCache.cpp
@@ +331,5 @@
>          static_cast<int64_t>(idealKey.Size().height);
> +      int64_t surfaceArea = static_cast<int64_t>(aSurfaceKey.Size().width) *
> +        static_cast<int64_t>(aSurfaceKey.Size().height);
> +      int64_t bestMatchArea = static_cast<int64_t>(bestMatchKey.Size().width) *
> +        static_cast<int64_t>(bestMatchKey.Size().height);

There's a lot of repetition here (the pattern as a whole is repeated 3 times, and each key.Size() is repeated twice within each instance of the pattern).  Makes for slightly-hard reading, and possibility for easy-to-miss mistakes.

So, I'd prefer we factored out a trivial helper function, defined right above this method if you like, e.g.

static int64_t
AreaOfIntSize(IntSize aSize) {
...
}

Then this could just be:
  int64_t idealArea = AreaOfIntSize(idealKey.Size());
  int64_t surfaceArea = AreaOfIntSize(surfaceKey.Size());
  int64_t bestMatchArea = AreaOfIntSize(bestMatchKey.Size());

r=me with that.
Attachment #8724244 - Flags: review?(dholbert) → review+
Sorry, I should've had "IntSize& aSize" in the helper-function signature (passing by reference instead of by copy).
Good idea. Made that change. Thanks!
I also had to make SurfaceKey::Size return a const IntSize& (instead of IntSize), and AreaOfIntSize take a const IntSize&.
Makes sense. Thanks!
https://hg.mozilla.org/integration/mozilla-inbound/rev/e4ae782bcc00
https://hg.mozilla.org/mozilla-central/rev/e4ae782bcc00
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
Comment on attachment 8724244 [details] [diff] [review]
patch

Need this for bug 1251091.

Approval Request Comment
[Feature/regressing bug #]: bug 1119774 added this code
[User impact if declined]: needed for bug 1251091
[Describe test coverage new/current, TreeHerder]: none
[Risks and why]: safe
[String/UUID change made/needed]: none
Attachment #8724244 - Flags: approval-mozilla-aurora?
Comment on attachment 8724244 [details] [diff] [review]
patch

More surface cache work, please uplift to aurora.
Timothy, hopefully you can keep an eye out for new regressions/crashes in 46 that might be related as we go into early beta.
Attachment #8724244 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: