Skip to content
Permalink
Browse files
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: https://svn.webkit.org/repository/webkit/trunk@295719 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
achristensen07 committed Jun 22, 2022
1 parent 6af6969 commit 79efdcf
Showing 1 changed file with 2 additions and 1 deletion.
@@ -836,7 +836,8 @@ struct VariantCoder<0, Types...> {
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)

0 comments on commit 79efdcf

Please sign in to comment.