From e89e2fd93a93751be0cec541dd4d14d24b38d8ac Mon Sep 17 00:00:00 2001 From: J Plasmeier Date: Mon, 29 Jan 2024 12:45:05 -0800 Subject: [PATCH] fix: throw an exception when MemoryStream instance has an empty backing array --- .../net/Generated/AwsEncryptionSdk/TypeConversion.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/AwsEncryptionSDK/runtimes/net/Generated/AwsEncryptionSdk/TypeConversion.cs b/AwsEncryptionSDK/runtimes/net/Generated/AwsEncryptionSdk/TypeConversion.cs index 73c53ea8a..91aed7400 100644 --- a/AwsEncryptionSDK/runtimes/net/Generated/AwsEncryptionSdk/TypeConversion.cs +++ b/AwsEncryptionSDK/runtimes/net/Generated/AwsEncryptionSdk/TypeConversion.cs @@ -754,6 +754,17 @@ public static System.IO.MemoryStream FromDafny_N6_smithy__N3_api__S4_Blob(Dafny. public static Dafny.ISequence ToDafny_N6_smithy__N3_api__S4_Blob(System.IO.MemoryStream value) { + // BEGIN MANUAL EDIT + // It is possible for a MemoryStream to be implemented by another stream, + // which may or may not be backed with an array. + // If the array is empty, but the stream isn't, then + // the backing stream cannot be treated as a MemoryStream + // for purposes of type conversion through ToArray(). + if (value.ToArray().Length == 0 && value.Length > 0) + { + throw new System.ArgumentException("Fatal Error: MemoryStream instance not backed by an array!"); + } + // END MANUAL EDIT return Dafny.Sequence.FromArray(value.ToArray()); }