Skip to content

Commit

Permalink
Fixed trying to read an invalid index from a TOMLArray.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolftein committed Nov 10, 2024
1 parent d17c655 commit abb01cf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Source/Public/Aurora.Base/IO/TOML/Array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ inline namespace IO

Bool TOMLArray::GetBool(UInt Index) const
{
return (* mArray)[Index].value_or(false);
Ptr<toml::node> Node = mArray->get(Index);
return Node ? Node->value_or(false) : false;
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Expand All @@ -120,7 +121,8 @@ inline namespace IO

CStr TOMLArray::GetString(UInt Index) const
{
return (* mArray)[Index].value_or("");
Ptr<toml::node> Node = mArray->get(Index);
return Node ? Node->value_or("") : 0;
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Expand All @@ -136,7 +138,8 @@ inline namespace IO

SInt TOMLArray::GetNumber(UInt Index) const
{
return (* mArray)[Index].value_or(Index);
Ptr<toml::node> Node = mArray->get(Index);
return Node ? Node->value_or(0) : 0;
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Expand All @@ -152,6 +155,7 @@ inline namespace IO

Real TOMLArray::GetReal(UInt Index) const
{
return (* mArray)[Index].value_or(0.0);
Ptr<toml::node> Node = mArray->get(Index);
return Node ? Node->value_or(0.0) : 0.0;
}
}

0 comments on commit abb01cf

Please sign in to comment.