From 40e016c8d12df5ae697b9eaa28d693db8dee3261 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Wed, 16 Sep 2020 14:03:51 -0400 Subject: [PATCH] don't assume that the number of bytes actually read/written are equal to what we asked for --- .../UniversalEditor.Core/Accessors/StreamAccessor.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Libraries/UniversalEditor.Core/Accessors/StreamAccessor.cs b/Libraries/UniversalEditor.Core/Accessors/StreamAccessor.cs index 915f6d1a..7bc3b04a 100644 --- a/Libraries/UniversalEditor.Core/Accessors/StreamAccessor.cs +++ b/Libraries/UniversalEditor.Core/Accessors/StreamAccessor.cs @@ -92,15 +92,18 @@ namespace UniversalEditor.Accessors { // TODO: will ct ever be != count? should we add ct to Position instead of count?? int ct = mvarBaseStream.Read(buffer, start, count); - // Position += count; - return count; + + // --->: apparently, ct sometimes DOES != count, and it's important here to return ct + // instead of count to prevent freezing on certain streams + return ct; } protected internal override int WriteInternal(byte[] buffer, int start, int count) { + long oldpos = Position; mvarBaseStream.Write(buffer, start, count); // Position += count; - return count; + return (int)(Position - oldpos); } protected override void OpenInternal()