From 7d23af49c22ba46e30fbfbc0c6f40672d4ca294a Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Mon, 13 Feb 2023 10:53:00 +0100 Subject: [PATCH] LibWeb: Avoid dereferencing null pointer Null check was missing and we would crash when dereferencing the pointer to access the type() member. --- Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp b/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp index 879377806a..8b87aa9740 100644 --- a/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp +++ b/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp @@ -83,7 +83,7 @@ WebIDL::ExceptionOr> construct_e } // 2. If the field element is an input element whose type attribute is in the Image Button state, then: - if (auto* input_element = dynamic_cast(control.ptr()); input_element->type() == "image") { + if (auto* input_element = dynamic_cast(control.ptr()); input_element && input_element->type() == "image") { // FIXME: 1. If the field element has a name attribute specified and its value is not the empty string, let name be that value followed by a single U+002E FULL STOP character (.). Otherwise, let name be the empty string. // FIXME: 2. Let namex be the string consisting of the concatenation of name and a single U0078 LATIN SMALL LETTER X character (x). // FIXME: 3. Let namey be the string consisting of the concatenation of name and a single U+0079 LATIN SMALL LETTER Y character (y).