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

Crash when serializing a string #102

Closed
nowol opened this issue Aug 26, 2016 · 1 comment
Closed

Crash when serializing a string #102

nowol opened this issue Aug 26, 2016 · 1 comment

Comments

@nowol
Copy link

nowol commented Aug 26, 2016

Hi,

I am using the latest version from Nuget (0.8, .Net 4.6.1) and I got an exception while serializing a string with more than 254 characters:

System.ArgumentOutOfRangeException: Non-negative number required.
Parameter name: count
    at System.IO.MemoryStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at Wire.Extensions.StreamEx.ReadString(Stream stream, DeserializerSession session)
   at Wire.ValueSerializers.StringSerializer.ReadValue(Stream stream, DeserializerSession session)

Is it related to issue #21?
I was able to replicate the bug with the following code:

        [TestMethod]
        public void MyTestMethod()
        {
            byte[] wireBytes;
            var wireSerializer = new Wire.Serializer();
            using (var ms = new MemoryStream())
            {
                var obj = new string('c', 1000);
                wireSerializer.Serialize(obj, ms);
                wireBytes = ms.ToArray();
            }
            using (var ms = new MemoryStream(wireBytes))
            {
                wireSerializer.Deserialize(ms);
            }
        }
@rogeralsing
Copy link
Collaborator

fixed in Dev now.
this was the result of some bad pointer calculations.
Thanks for reporting

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

No branches or pull requests

2 participants