Skip to content

Commit

Permalink
Fix: Unexpected closing tag caused segfaults
Browse files Browse the repository at this point in the history
E.g. the following minimal XML file caused segmentation faults:
```
</if>
```

This is fixed by throwing an appropriate error instead.
  • Loading branch information
2xB authored Jun 10, 2024
1 parent 805765f commit 185aa0b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Kommon/Core/Initialization/KXMLTokenizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,17 @@ void KXMLTokenizer::ParseElementEndName()

//if at ">", then check and send end element, then prepare value, then ParseBody
if (AtOneOf(fRightAngle)) {
if (fNames.empty()) {
fBuffer = string("no element open but got unexpected closing tag for element <") + fBuffer +
string(">");
fError->SetValue(fBuffer);
fError->SetLine(fLine);
fError->SetColumn(fColumn);
ProcessToken(fError);
fState = fFinalState;
return;
}

if (fNames.top() != fBuffer) {
fBuffer = string("expected closing element name <") + fNames.top() + string(">, but got <") + fBuffer +
string("> instead");
Expand Down

0 comments on commit 185aa0b

Please sign in to comment.