Skip to content

Commit 550c714

Browse files
authored
fix: throw an exception when MemoryStream instance has an empty backing array
2 parents 3c36f7a + e89e2fd commit 550c714

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

AwsEncryptionSDK/runtimes/net/Generated/AwsEncryptionSdk/TypeConversion.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,17 @@ public static System.IO.MemoryStream FromDafny_N6_smithy__N3_api__S4_Blob(Dafny.
754754

755755
public static Dafny.ISequence<byte> ToDafny_N6_smithy__N3_api__S4_Blob(System.IO.MemoryStream value)
756756
{
757+
// BEGIN MANUAL EDIT
758+
// It is possible for a MemoryStream to be implemented by another stream,
759+
// which may or may not be backed with an array.
760+
// If the array is empty, but the stream isn't, then
761+
// the backing stream cannot be treated as a MemoryStream
762+
// for purposes of type conversion through ToArray().
763+
if (value.ToArray().Length == 0 && value.Length > 0)
764+
{
765+
throw new System.ArgumentException("Fatal Error: MemoryStream instance not backed by an array!");
766+
}
767+
// END MANUAL EDIT
757768
return Dafny.Sequence<byte>.FromArray(value.ToArray());
758769
}
759770

0 commit comments

Comments
 (0)