mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 01:00:05 +00:00
LibWeb: Don't crash when drawing null image from offscreen canvas
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This commit is contained in:
parent
55129644d5
commit
28774efa22
Notes:
github-actions[bot]
2025-07-20 06:56:10 +00:00
Author: https://github.com/Gingeh
Commit: 28774efa22
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5518
2 changed files with 26 additions and 1 deletions
|
@ -144,7 +144,10 @@ WebIDL::ExceptionOr<void> CanvasRenderingContext2D::draw_image_internal(CanvasIm
|
|||
},
|
||||
[](GC::Root<HTMLVideoElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> { return Gfx::ImmutableBitmap::create(*source->bitmap()); },
|
||||
[](GC::Root<ImageBitmap> const& source) -> RefPtr<Gfx::ImmutableBitmap> {
|
||||
return Gfx::ImmutableBitmap::create(*source->bitmap());
|
||||
auto* bitmap = source->bitmap();
|
||||
if (!bitmap)
|
||||
return {};
|
||||
return Gfx::ImmutableBitmap::create(*bitmap);
|
||||
});
|
||||
if (!bitmap)
|
||||
return {};
|
||||
|
|
22
Tests/LibWeb/Crash/JS/draw-from-offscreen-canvas.html
Normal file
22
Tests/LibWeb/Crash/JS/draw-from-offscreen-canvas.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<canvas id="canvas" width="100" height="50">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script id='myWorker' type='text/worker'>
|
||||
self.onmessage = function(e) {
|
||||
const canvas = new OffscreenCanvas(100, 50);
|
||||
const ctx = canvas.getContext('2d');
|
||||
const bitmap = canvas.transferToImageBitmap();
|
||||
self.postMessage(bitmap, bitmap);
|
||||
};
|
||||
</script>
|
||||
<script>
|
||||
const blob = new Blob([document.getElementById('myWorker').textContent]);
|
||||
const worker = new Worker(URL.createObjectURL(blob));
|
||||
worker.addEventListener('message', msg => {
|
||||
const outputCtx = document.getElementById("canvas").getContext('2d');
|
||||
outputCtx.drawImage(msg.data, 0, 0);
|
||||
});
|
||||
worker.postMessage(null);
|
||||
</script>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue