-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8e76b0
commit 675f212
Showing
3 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace BinarySerialization.Test.Issues.Issue180 | ||
{ | ||
[TestClass] | ||
public class Issue180Tests : TestBase | ||
{ | ||
public class BitFieldsPrecededByByte | ||
{ | ||
[FieldOrder(0)] | ||
public byte First; | ||
|
||
[FieldOrder(1)] | ||
[FieldBitLength(7)] | ||
public byte SevenBits; | ||
|
||
[FieldOrder(2)] | ||
[FieldBitLength(1)] | ||
public byte OneBit; | ||
} | ||
|
||
[TestMethod] | ||
public void TestOutOfMemory() | ||
{ | ||
for (int i = 0; i < 7; i++) | ||
{ | ||
Console.WriteLine($"Trying to deserialize array of partial {nameof(BitFieldsPrecededByByte)} with array size {i}"); | ||
var serialized = new byte[i]; | ||
// This call will never return and consumes all available memory | ||
var _ = Deserialize<BitFieldsPrecededByByte[]>(serialized); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters