Browse Source

LibGfx: assert Bitmap::set_pixel does not write out of bounds

Peter Nelson 4 năm trước cách đây
mục cha
commit
23c4f1a3d4
1 tập tin đã thay đổi với 2 bổ sung0 xóa
  1. 2 0
      Libraries/LibGfx/Bitmap.h

+ 2 - 0
Libraries/LibGfx/Bitmap.h

@@ -300,11 +300,13 @@ inline Color Bitmap::get_pixel(int x, int y) const
 template<>
 inline void Bitmap::set_pixel<StorageFormat::RGB32>(int x, int y, Color color)
 {
+    ASSERT(rect().contains(x, y));
     scanline(y)[x] = color.value();
 }
 template<>
 inline void Bitmap::set_pixel<StorageFormat::RGBA32>(int x, int y, Color color)
 {
+    ASSERT(rect().contains(x, y));
     scanline(y)[x] = color.value(); // drop alpha
 }
 inline void Bitmap::set_pixel(int x, int y, Color color)