Skip to content

Commit

Permalink
Fix crash for empty documentation comment keyword where '<' occurs…
Browse files Browse the repository at this point in the history
… at line end.
  • Loading branch information
nyamatongwe committed Oct 17, 2024
1 parent 0784d05 commit 5bd3f0f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc/Lexilla.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
</tr>
</table>
<ul id="versionlist">
<li>Version 5.4.1 adds Dart, troff, and Zig lexers. Improves F#, HTML, and Smalltalk.</li>
<li>Version 5.4.1 adds Dart, troff, and Zig lexers. Improves C++, F#, HTML, and Smalltalk.</li>
<li>Version 5.4.0 adds a TOML lexer.</li>
<li>Version 5.3.3 improves HTML, JavaScript, Lua, PHP, and XML.</li>
<li>Version 5.3.2 improves COBOL, HTML, Lua, Ruby, and Rust.</li>
Expand Down
3 changes: 3 additions & 0 deletions doc/LexillaHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,9 @@ <h3>
<a href="https://github.com/ScintillaOrg/lexilla/pull/267">Pull request #267</a>.
</li>
<li>
C++: Fix crash for empty documentation comment keyword where '&lt;' occurs at line end.
</li>
<li>
F#: Include EOLs in the style range of SCE_FSHARP_COMMENTLINE.
Stabilizes EOL detection when folding line comment groups.
<a href="https://github.com/ScintillaOrg/lexilla/issues/276">Issue #276</a>.
Expand Down
2 changes: 1 addition & 1 deletion lexers/LexCPP.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i
styleBeforeDCKeyword = SCE_C_COMMENTDOC;
sc.SetState(SCE_C_COMMENTDOCKEYWORD|activitySet);
}
} else if ((sc.ch == '<' && sc.chNext != '/')
} else if ((sc.ch == '<' && !(IsASpace(sc.chNext) || sc.chNext == '/'))
|| (sc.ch == '/' && sc.chPrev == '<')) { // XML comment style
styleBeforeDCKeyword = SCE_C_COMMENTDOC;
sc.ForwardSetState(SCE_C_COMMENTDOCKEYWORD | activitySet);
Expand Down
2 changes: 2 additions & 0 deletions test/examples/cpp/x.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ b
/** Unknown doc keywords so in SCE_C_COMMENTDOCKEYWORDERROR:
@wrong LexCPP.cxx
<wrong>filename</wrong>
Next line should not start a keyword but before 5.4.1 did and caused bad styling or a crash depending on range lexed
<
**/

#define M\
Expand Down
2 changes: 2 additions & 0 deletions test/examples/cpp/x.cxx.folded
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
2 400 401 + /** Unknown doc keywords so in SCE_C_COMMENTDOCKEYWORDERROR:
0 401 401 | @wrong LexCPP.cxx
0 401 401 | <wrong>filename</wrong>
0 401 401 | Next line should not start a keyword but before 5.4.1 did and caused bad styling or a crash depending on range lexed
0 401 401 | <
0 401 400 | **/
1 400 400
0 400 400 #define M\
Expand Down
2 changes: 2 additions & 0 deletions test/examples/cpp/x.cxx.styled
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
{3}/** Unknown doc keywords so in SCE_C_COMMENTDOCKEYWORDERROR:
{18}@wrong{3} LexCPP.cxx
<{18}wrong{3}>filename</{18}wrong{3}>
Next line should not start a keyword but before 5.4.1 did and caused bad styling or a crash depending on range lexed
<
**/{0}

{9}#define M\
Expand Down

0 comments on commit 5bd3f0f

Please sign in to comment.