Skip to content

Fix crash in comment parsing (fixes #1616)#1890

Merged
alexander-fenster merged 1 commit intoprotobufjs:masterfrom
simon-paris:fix-comment-parsing
Aug 21, 2023
Merged

Fix crash in comment parsing (fixes #1616)#1890
alexander-fenster merged 1 commit intoprotobufjs:masterfrom
simon-paris:fix-comment-parsing

Conversation

@simon-paris
Copy link
Copy Markdown

This fixes a crash in parsing sequences of comments like the following:

//
/*
*/

The conditions to trigger the crash are:

  1. alternateCommentMode is set to true
  2. A single line comment is immediately followed by a block comment
  3. The block comment spans at least two lines

The crash happens because isDoubleSlashCommentLine returns true for lines starting with /*. It only checks for one slash because in the first callsite, offset points to the second slash character and the character before it is guaranteed to also be a slash. But this is not true in the second callsite. The result is that it treats the line with /* as a single line comment.

@alexander-fenster alexander-fenster merged commit eaf9f0a into protobufjs:master Aug 21, 2023
@alexander-fenster
Copy link
Copy Markdown
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants