std::variant decoding with out-of-bounds index should fail instead of decoding the 0'th type
https://bugs.webkit.org/show_bug.cgi?id=241813

Reviewed by Chris Dumez.

* Source/WebKit/Platform/IPC/ArgumentCoders.h:

Canonical link: https://commits.webkit.org/251724@main


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@295719 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebKit/Platform/IPC/ArgumentCoders.h b/Source/WebKit/Platform/IPC/ArgumentCoders.h
index 5e58c2c..3f7334d 100644
--- a/Source/WebKit/Platform/IPC/ArgumentCoders.h
+++ b/Source/WebKit/Platform/IPC/ArgumentCoders.h
@@ -836,7 +836,8 @@
     template<typename Decoder>
     static std::optional<std::variant<Types...>> decode(Decoder& decoder, unsigned i)
     {
-        ASSERT_UNUSED(i, !i);
+        if (i)
+            return std::nullopt;
         std::optional<typename std::variant_alternative<0, std::variant<Types...>>::type> optional;
         decoder >> optional;
         if (!optional)