[CSHARP-2465] BsonSerializer.Deserialize throws OutOfMemoryException on a small input array (19 bytes) Created: 27/Dec/18  Updated: 27/Oct/23  Resolved: 27/Dec/18

Status: Closed
Project: C# Driver
Component/s: BSON
Affects Version/s: 2.7.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Squidward Tentacles Assignee: Dmitry Lukyanov (Inactive)
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

.NET Core 2.1


Attachments: File Program.cs    

 Description   

BsonSerializer.Deserialize throws OutOfMemoryException on a small input array (19 bytes). The full C# program that reproduces this bug is attached.



 Comments   
Comment by Dmitry Lukyanov (Inactive) [ 27/Dec/18 ]

Hi, your example has the corrupted BSON.

The driver tries to create the string with too large length: 2147483647. So, the error reason is based on .net memory restriction:doc

The driver is doing the right thing.

Please let me know if you still have questions.

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