Dont allow setting to a userdata field if it has no setter

This commit is contained in:
Deukhoofd 2019-09-20 18:15:48 +02:00
parent 99c91164be
commit 0763ebbad0
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 4 additions and 0 deletions

View File

@ -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);
}