[CSHARP-880] System.IndexOutOfRange Exception in Check Created: 17/Dec/13  Updated: 20/Mar/14  Resolved: 20/Mar/14

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.8.3
Fix Version/s: 1.9

Type: Bug Priority: Critical - P2
Reporter: Gustavo Gondim Assignee: Unassigned
Resolution: Done Votes: 0
Labels: bsonwriter
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

.NET Framework 4.5.1, ASP.NET MVC 5, Windows 8.1


Attachments: PNG File bug.png     PNG File test case.png    
Issue Links:
Duplicate
duplicates CSHARP-893 MongoDB.Bson.Serialization.Serializer... Closed
Backwards Compatibility: Minor Change

 Description   

When passing an empty dictionary key of type string, the serializer breaks inside the CheckElementName method (BsonWriter.cs)

The bug is thrown because the code tries to access the zero index of string-char array. As the string is empty, there is no indexes for the char array.

I suggest a verification of the element name to test if it is empty, and if it is, throw the BsonSerializationException with a proper message.

I can contribute to this bug resolution in GitHub if I will be authorized.

Thank you all.

(See attachments for a better analysis)


Generated at Wed Feb 07 21:38:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.