You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.
The Write method always adds the buffer's length to the stream's length which causes an incorrect value when the position is not at the end of the stream. The fix is to change
length += count;
on line 84 to
length = Math.Max(length, position);
You can test this as follows:
using System;
using System.IO;
using ScintillaNET;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ScintillaNET.Tests
{
[TestClass]
public class NativeMemoryStreamTests
{
[TestMethod]
public void StreamLengthTest()
{
// the way it ought to work
StreamLengthTest(() => new MemoryStream());
// the way we work
StreamLengthTest(() => new NativeMemoryStream(10));
}
The Write method always adds the buffer's length to the stream's length which causes an incorrect value when the position is not at the end of the stream. The fix is to change
length += count;
on line 84 to
length = Math.Max(length, position);
You can test this as follows:
using System;
using System.IO;
using ScintillaNET;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ScintillaNET.Tests
{
[TestClass]
public class NativeMemoryStreamTests
{
[TestMethod]
public void StreamLengthTest()
{
// the way it ought to work
StreamLengthTest(() => new MemoryStream());
// the way we work
StreamLengthTest(() => new NativeMemoryStream(10));
}
}
The text was updated successfully, but these errors were encountered: