Bug 1921797 - Check for degenerate ratio in nsCocoaUtis. r=mac-reviewers,mstange,bradwerth a=RyanVM

This is the straight-forward, uncontroversial fix, that can be uplifted.

Differential Revision: https://phabricator.services.mozilla.com/D224211
This commit is contained in:
Emilio Cobos Álvarez 2024-10-01 20:31:41 +00:00
parent 4d0702759a
commit 5e26dbfdc7

View file

@ -523,7 +523,7 @@ nsresult nsCocoaUtils::CreateNSImageFromImageContainer(
{
const bool gotWidth = NS_SUCCEEDED(aImage->GetWidth(&width));
const bool gotHeight = NS_SUCCEEDED(aImage->GetHeight(&height));
if (auto ratio = aImage->GetIntrinsicRatio()) {
if (auto ratio = aImage->GetIntrinsicRatio(); ratio && *ratio) {
if (gotWidth != gotHeight) {
if (gotWidth) {
height = ratio->Inverted().ApplyTo(width);