Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

simon-paris
Copy link
Contributor

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
Contributor

Thank you!

@github-actions github-actions bot mentioned this pull request Aug 21, 2023
@simon-paris simon-paris deleted the fix-comment-parsing branch April 12, 2024 08:06
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.

None yet

2 participants