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

Exception if string is indented by more spaces than the MaxBufferLength in Scanner.cs #511

Open
stuartbean opened this issue Jul 15, 2020 · 0 comments
Labels

Comments

@stuartbean
Copy link

Literal: |2-
          <hr>

This yaml (valid as far as I can tell) causes exception in Scanner.cs due to the following code exceeding the buffer:

                // Have we find a non-empty line?

                if (!analyzer.IsBreak())
                {
                    if (isLiteral && isFirstLine == true)
                    {
                        int localIndent = cursor.LineOffset;
                        int i = 0;
                        for (; !analyzer.IsBreak(i) && analyzer.IsSpace(i); ++i, ++localIndent) ; // BUG HERE
                        if (analyzer.IsBreak(i) && localIndent > cursor.LineOffset)
                        {
                            isFirstLine = false;
                            indentOfFirstLine = localIndent;
                        }
                    }
                    break;
                }

I cannot work out how to modify this code to achieve its original intent and protect against exceeding the buffer overrun. For now I've simply added a limit check in the for loop. I'll put up a PR with the unit test and "fix".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants