From 0763ebbad0d52d61ad5c7e0d4302ae7d992d357f Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 20 Sep 2019 18:15:48 +0200 Subject: [PATCH] Dont allow setting to a userdata field if it has no setter --- src/UserData/UserDataScriptType.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/UserData/UserDataScriptType.hpp b/src/UserData/UserDataScriptType.hpp index 45cd35b..d7ba5f0 100644 --- a/src/UserData/UserDataScriptType.hpp +++ b/src/UserData/UserDataScriptType.hpp @@ -84,6 +84,8 @@ namespace Porygon::UserData { if (!ud->ContainsField(hash.GetHash())) return false; auto field = _userData->Get()->GetField(hash.GetHash()); + if (!field->HasSetter()) + return false; return (val->CastableTo(field->GetType(), false) != CastResult::InvalidCast); } @@ -93,6 +95,8 @@ namespace Porygon::UserData { if (!ud->ContainsField(indexer.GetHash())) return false; auto field = _userData->Get()->GetField(indexer.GetHash()); + if (!field->HasSetter()) + return false; return (val->CastableTo(field->GetType(), false) != CastResult::InvalidCast); }