From 6cfa888b4df1e7be03e14e411083615d978dc141 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Wed, 12 Apr 2023 22:29:11 +0200 Subject: [PATCH] Fixed an issue where using the cropSize property could lead to a crash under very rare circumstances --- es-core/src/components/ImageComponent.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/es-core/src/components/ImageComponent.cpp b/es-core/src/components/ImageComponent.cpp index 6c8800f1a..4d9f6e4f7 100644 --- a/es-core/src/components/ImageComponent.cpp +++ b/es-core/src/components/ImageComponent.cpp @@ -222,13 +222,13 @@ void ImageComponent::coverFitCrop() mBottomRightCrop = {1.0f, 1.0f}; if (std::round(mSize.y) > std::round(mTargetSize.y)) { - const float cropSize {1.0f - (mTargetSize.y / std::round(mSize.y))}; + const float cropSize {1.0f - (std::round(mTargetSize.y) / std::round(mSize.y))}; cropTop(cropSize / 2.0f); cropBottom(cropSize / 2.0f); mSize.y = mSize.y - (mSize.y * cropSize); } else { - const float cropSize {1.0f - (mTargetSize.x / std::round(mSize.x))}; + const float cropSize {1.0f - (std::round(mTargetSize.x) / std::round(mSize.x))}; cropLeft(cropSize / 2.0f); cropRight(cropSize / 2.0f); mSize.x = mSize.x - (mSize.x * cropSize);