Skip to content

Commit

Permalink
[parser] Fix dynamically-sized array initializer causing the parser t…
Browse files Browse the repository at this point in the history
…o lock up.

Also fix a debug assertion along the way.
  • Loading branch information
c-lipka committed Nov 28, 2018
1 parent a969d8f commit a9eb1a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/parser/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11224,13 +11224,13 @@ bool Parser::POV_ARRAY::HasElement(size_t i) const

const int& Parser::POV_ARRAY::ElementType(size_t i) const
{
POV_PARSER_ASSERT(i < DataPtrs.size());
POV_PARSER_ASSERT(resizable || (i < DataPtrs.size()));
return (mixedType ? Types[i] : Type_);
}

int& Parser::POV_ARRAY::ElementType(size_t i)
{
POV_PARSER_ASSERT(i < DataPtrs.size());
POV_PARSER_ASSERT(resizable || (i < DataPtrs.size()));
return (mixedType ? Types[i] : Type_);
}

Expand Down
3 changes: 3 additions & 0 deletions source/parser/parser_tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3931,8 +3931,11 @@ void Parser::Parse_Initalizer (int Sub, size_t Base, POV_ARRAY *a)

CASE (RIGHT_CURLY_TOKEN)
if (a->resizable)
{
finalParameter = true;
// We reserved one element too many.
a->Shrink();
}
else
{
if (!(finalParameter && properlyDelimited))
Expand Down

0 comments on commit a9eb1a6

Please sign in to comment.