Skip to content

Commit a9eb1a6

Browse files
committed
[parser] Fix dynamically-sized array initializer causing the parser to lock up.
Also fix a debug assertion along the way.
1 parent a969d8f commit a9eb1a6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

source/parser/parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11224,13 +11224,13 @@ bool Parser::POV_ARRAY::HasElement(size_t i) const
1122411224

1122511225
const int& Parser::POV_ARRAY::ElementType(size_t i) const
1122611226
{
11227-
POV_PARSER_ASSERT(i < DataPtrs.size());
11227+
POV_PARSER_ASSERT(resizable || (i < DataPtrs.size()));
1122811228
return (mixedType ? Types[i] : Type_);
1122911229
}
1123011230

1123111231
int& Parser::POV_ARRAY::ElementType(size_t i)
1123211232
{
11233-
POV_PARSER_ASSERT(i < DataPtrs.size());
11233+
POV_PARSER_ASSERT(resizable || (i < DataPtrs.size()));
1123411234
return (mixedType ? Types[i] : Type_);
1123511235
}
1123611236

source/parser/parser_tokenizer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3931,8 +3931,11 @@ void Parser::Parse_Initalizer (int Sub, size_t Base, POV_ARRAY *a)
39313931

39323932
CASE (RIGHT_CURLY_TOKEN)
39333933
if (a->resizable)
3934+
{
3935+
finalParameter = true;
39343936
// We reserved one element too many.
39353937
a->Shrink();
3938+
}
39363939
else
39373940
{
39383941
if (!(finalParameter && properlyDelimited))

0 commit comments

Comments
 (0)