Skip to content

Commit

Permalink
Add null check in CheckboxInputType::performSwitchAnimation
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=267429
rdar://120841254

Reviewed by Tim Nguyen.

* LayoutTests/fast/forms/checkbox-click-without-renderer-expected.txt: Added.
* LayoutTests/fast/forms/checkbox-click-without-renderer.html: Added.
* Source/WebCore/html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::performSwitchAnimation):

Canonical link: https://commits.webkit.org/272956@main
  • Loading branch information
achristensen07 authored and nt1m committed Jan 12, 2024
1 parent 67e8a20 commit c620752
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This test passes if it does not crash.
10 changes: 10 additions & 0 deletions LayoutTests/fast/forms/checkbox-click-without-renderer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script>
if (window.testRunner) { testRunner.dumpAsText() }
let input0 = document.createElement('input');
input0.type = 'checkbox';
input0.switch = true;
let label0 = document.createElement('label');
label0.append(input0);
label0.click();
</script>
This test passes if it does not crash.
4 changes: 1 addition & 3 deletions Source/WebCore/html/CheckboxInputType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,7 @@ void CheckboxInputType::performSwitchAnimation(SwitchAnimationType type)
{
ASSERT(isSwitch());
ASSERT(element());
ASSERT(element()->renderer());

if (!element()->renderer()->style().hasEffectiveAppearance())
if (!element()->renderer() || !element()->renderer()->style().hasEffectiveAppearance())
return;

auto updateInterval = switchAnimationUpdateInterval(element());
Expand Down

0 comments on commit c620752

Please sign in to comment.