LibWeb: Null-check surface before allocating painter for context2d

Fixes https://github.com/LadybirdBrowser/ladybird/issues/2755
This commit is contained in:
Aliaksandr Kalenik 2024-12-04 16:22:27 +01:00 committed by Alexander Kalenik
commit 72f093ba9f
Notes: github-actions[bot] 2024-12-04 15:59:49 +00:00
3 changed files with 17 additions and 3 deletions

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<script src="../include.js"></script>
<canvas id="myCanvas" width="0" height="0"></canvas>
<script>
test(() => {
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, canvas.width, canvas.height);
println("PASS (didn't crash!)");
});
</script>