summaryrefslogtreecommitdiff
path: root/Meta
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-10-11 12:54:05 +0100
committerLinus Groh <mail@linusgroh.de>2021-10-11 13:30:17 +0100
commit7afd215e95518392f67f233f835e944a803bf17a (patch)
treeddc6ebaf0ecf60040fcf57872d998ad8a0c18bc4 /Meta
parenta9a7d650993da877ecf59a6cf052d72661315739 (diff)
downloadserenity-7afd215e95518392f67f233f835e944a803bf17a.zip
LibWeb: Initialize IDL `any` values without default value to undefined
Previously this would generate the following code: JS::Value foo_value; if (!foo.is_undefined()) foo_value = foo; Which is dangerous as we're passing an empty value around, which could be exposed to user code again. This is fine with "= null", for which it also generates: else foo_value = JS::js_null(); So, in summary: a value of type `any`, not `required`, with no default value and no initializer from user code will now default to undefined instead of an empty value.
Diffstat (limited to 'Meta')
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp
index 9ca2a40ef6..e093743be5 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp
@@ -1079,7 +1079,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
)~~~");
} else {
scoped_generator.append(R"~~~(
- JS::Value @cpp_name@;
+ JS::Value @cpp_name@ = JS::js_undefined();
if (!@js_name@@js_suffix@.is_undefined())
@cpp_name@ = @js_name@@js_suffix@;
)~~~");