summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-04-15 17:15:06 +0200
committerAndreas Kling <kling@serenityos.org>2020-04-15 17:15:06 +0200
commitacf20618378124b9c0d10fb55b741e98c566b91f (patch)
treeb52e23d6f154d42022c5ef703a3649bd6737002d
parent63b8c6913cea1bca0507e8d11e17afbe7560721b (diff)
downloadserenity-acf20618378124b9c0d10fb55b741e98c566b91f.zip
LibGfx: Use Checked::multiplication_would_overflow()
-rw-r--r--Libraries/LibGfx/Bitmap.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/Libraries/LibGfx/Bitmap.cpp b/Libraries/LibGfx/Bitmap.cpp
index 84bfe4e0ea..e7a467a177 100644
--- a/Libraries/LibGfx/Bitmap.cpp
+++ b/Libraries/LibGfx/Bitmap.cpp
@@ -43,10 +43,7 @@ static bool size_would_overflow(BitmapFormat format, const Size& size)
{
if (size.width() < 0 || size.height() < 0)
return true;
- Checked<size_t> size_in_bytes = static_cast<size_t>(size.width());
- size_in_bytes *= size.height();
- size_in_bytes *= Bitmap::bpp_for_format(format);
- return size_in_bytes.has_overflow();
+ return Checked<size_t>::multiplication_would_overflow(size.width(), size.height(), Bitmap::bpp_for_format(format));
}
RefPtr<Bitmap> Bitmap::create(BitmapFormat format, const Size& size)