evgenekov / protobuf-csharp-port

Automatically exported from code.google.com/p/protobuf-csharp-port
Other
0 stars 0 forks source link

ToJson() can throw IndexOutOfRangeException #64

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

string s = new string('.', 4086);
var opts = 
Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto.CreateBuilder()
   .SetName(s)
   .SetPackage("package")
   .BuildPartial();

string t = opts.ToJson();

What is the expected output? What do you see instead?

Expect json string, instead see IndexOutOfRangeException thrown. 

What version of the product are you using? On what operating system?

* 2.4.1.521 from nuget.

Please provide any additional information below.

* JsonTextWriter needs to check _output for null before calling Flush() when 
writing a single character like it does when writing an array.

* Work-around is to not use built-in ToJson() extension, but instead use one 
that supplies a MemoryStream.

  JsonFormatWriter w = JsonFormatWriter.CreateInstance(new MemoryStream());

Original issue reported on code.google.com by jacobgla...@yahoo.com on 12 Aug 2013 at 5:04

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 67a34e2b681e.

Original comment by jonathan.skeet on 13 Aug 2013 at 2:15