From 1f907a834fa8923766ab8767b38786c5b2eb8828 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 19 Feb 2023 22:24:45 +0100 Subject: [PATCH] LibGfx: Make Bitmap::scaled(1) return a clone While returning the same image is a cute optimization, it violates the expectation that the returned Bitmap is a new bitmap, not shared with anyone else. --- Userland/Libraries/LibGfx/Bitmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index db03f7234e..5bc238f8d1 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -343,7 +343,7 @@ ErrorOr> Bitmap::scaled(int sx, int sy) const { VERIFY(sx >= 0 && sy >= 0); if (sx == 1 && sy == 1) - return NonnullRefPtr { *this }; + return clone(); auto new_bitmap = TRY(Gfx::Bitmap::create(format(), { width() * sx, height() * sy }, scale()));