From 302b12cda82e8e40d541065f2a4518b76396b0e3 Mon Sep 17 00:00:00 2001 From: nattthebear Date: Fri, 18 Sep 2020 18:10:40 -0400 Subject: [PATCH] Remove infinite loop on certain stream copy failures Instead we get an error message now --- src/BizHawk.BizInvoke/WaterboxUtils.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/BizHawk.BizInvoke/WaterboxUtils.cs b/src/BizHawk.BizInvoke/WaterboxUtils.cs index 3c69c447af..89eef14588 100644 --- a/src/BizHawk.BizInvoke/WaterboxUtils.cs +++ b/src/BizHawk.BizInvoke/WaterboxUtils.cs @@ -15,6 +15,8 @@ namespace BizHawk.BizInvoke while (len > 0) { int r = src.Read(buff, 0, (int)Math.Min(len, 65536)); + if (r == 0) + throw new InvalidOperationException($"End of source stream was reached with {len} bytes left to copy!"); dst.Write(buff, 0, r); len -= r; }