-
-
Notifications
You must be signed in to change notification settings - Fork 492
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
Error reading from large streams using YamlStream / Parser #560
Comments
Thanks for the repro. I'll look into it. |
I managed to find the cause of the error. Thanks to your repro it was easy. The code that read from the stream was assuming that it would always get the amount of bytes that it requested unless the end of file was reached. In the case of network streams, that's not the case. I'm surprised that this bug did not come up sooner. I guess that most people parse from files, and that the implementation happens to always return the requested amount of bytes. Fixing the issue was just a matter of adding a loop to ensure that we read as much as we need. I'll publish a release now so that you can try the fix. |
I have published a pre-release version of the package that should fix aother related error. You may prefer to test with that version? Install-Package YamlDotNet -Version 9.1.4-fix-issues-553-562-0001 Thanks. |
I just tested this with the latest library using the sample code provided and could not reproduce it, since aaubry mentioned he already fixed it and no response in the past year and a half, I'm going to close this issue. |
This is related to #407 but with a very simple reproduction case. I just briefly toured the code, but I suspect the error is an off-by-one error (or something) in the LookAheadBuffer?
Note that, depending the stream reader's underlying source, it'll work or not work:.
responseStream
andnew BufferedStream(responseStream, 64 * 1024)
fail with a gives a duplicate key errornew StreamReader(responseStream).ReadToEnd()
works fineThis is for .NET 452, though I doubt it would matter.
The text was updated successfully, but these errors were encountered: