Skip to content

Commit

Permalink
libstd: Fixed crash when getting an out-of-range attribute value
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Feb 9, 2025
1 parent 57f7738 commit da45d0c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/source/pl/lib/std/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ namespace pl::lib::libstd::core {
auto &attributes = pattern->getAttributes();
if (attributes == nullptr || !attributes->contains(attributeName))
return std::string();
else
return attributes->at(attributeName)[index];
else {
const auto &attribute = attributes->at(attributeName);
if (index >= attributes->size())
err::E0012.throwError("Attribute argument index out of range");
else
return attribute[index];
}
});

/* set_pattern_color(pattern, color) */
Expand Down

0 comments on commit da45d0c

Please sign in to comment.