From 6d54e5ce9af5223f7b055383b666944856a3f2df Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Fri, 6 Jan 2023 19:12:42 +0100 Subject: [PATCH] LibWeb: Verify optional argument has a value before static_cast-ing it --- Userland/Libraries/LibWeb/FileAPI/File.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/FileAPI/File.cpp b/Userland/Libraries/LibWeb/FileAPI/File.cpp index 52f4297189..75b3940a6c 100644 --- a/Userland/Libraries/LibWeb/FileAPI/File.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/File.cpp @@ -24,7 +24,7 @@ File::~File() = default; WebIDL::ExceptionOr> File::create(JS::Realm& realm, Vector const& file_bits, DeprecatedString const& file_name, Optional const& options) { // 1. Let bytes be the result of processing blob parts given fileBits and options. - auto bytes = TRY_OR_RETURN_OOM(realm, process_blob_parts(file_bits, static_cast const&>(*options))); + auto bytes = TRY_OR_RETURN_OOM(realm, process_blob_parts(file_bits, options.has_value() ? static_cast(*options) : Optional {})); // 2. Let n be the fileName argument to the constructor. // NOTE: Underlying OS filesystems use differing conventions for file name; with constructed files, mandating UTF-16 lessens ambiquity when file names are converted to byte sequences.