1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:57:44 +00:00

LibGfx: Don't use unbounded VLA's in FastBoxBlurFilter

These would cause the stack to overflow when LibWeb tried rendering a
CSS box-shadow for a large enough element.

Use Vector (with *some* inline capacity for smaller images) to avoid
this issue. If these heap allocations turn out to be too much work,
we can add something like a persistent scratch buffer cache.
This commit is contained in:
Andreas Kling 2021-09-17 13:12:46 +02:00
parent 4fcb1be734
commit f9a38fa693

View file

@ -28,10 +28,15 @@ public:
int div = 2 * radius + 1;
u8 intermediate_red[width * height];
u8 intermediate_green[width * height];
u8 intermediate_blue[width * height];
u8 intermediate_alpha[width * height];
Vector<u8, 1024> intermediate_red;
Vector<u8, 1024> intermediate_green;
Vector<u8, 1024> intermediate_blue;
Vector<u8, 1024> intermediate_alpha;
intermediate_red.resize(width * height);
intermediate_green.resize(width * height);
intermediate_blue.resize(width * height);
intermediate_alpha.resize(width * height);
// First pass: vertical
for (int y = 0; y < height; ++y) {