Browse Source

sfzero: fix crash on multi-line c-style comments

Fixes #1183

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.2.0-RC1
falkTX 4 years ago
parent
commit
b7a906a0b6
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
1 changed files with 37 additions and 4 deletions
  1. +37
    -4
      source/modules/sfzero/sfzero/SFZReader.cpp

+ 37
- 4
source/modules/sfzero/sfzero/SFZReader.cpp View File

@@ -41,6 +41,7 @@ void Reader::read(const char *text, unsigned int length)
Region curGroup;
Region curRegion;
Region *buildingRegion = nullptr;
bool inComment = false;
bool inControl = false;
bool inGroup = false;
water::String defaultPath;
@@ -65,15 +66,31 @@ void Reader::read(const char *text, unsigned int length)
// Check if it's a comment line.
if (c == '/')
{
// Skip to end of line.
while (p < end)
// Skip to end of line or c-style comment.
do
{
c = *++p;
if (c == '*')
{
inComment = true;
continue;
}
if (inComment)
{
if (c != '*')
continue;
c = *++p;
if (c != '/')
continue;
inComment = false;
}
if ((c == '\n') || (c == '\r'))
{
break;
}
}
while (p < end);
inComment = false;
p = handleLineEnd(p);
continue;
}
@@ -164,16 +181,32 @@ void Reader::read(const char *text, unsigned int length)
// Comment.
else if (c == '/')
{
// Skip to end of line.
while (p < end)
// Skip to end of line or c-style comment.
do
{
c = *p;
if (c == '*')
{
inComment = true;
continue;
}
if (inComment)
{
if (c != '*')
continue;
c = *++p;
if (c != '/')
continue;
inComment = false;
}
if ((c == '\r') || (c == '\n'))
{
break;
}
p += 1;
}
while (p < end);
inComment = false;
}
// Parameter.
else


Loading…
Cancel
Save