Skip to content

Commit 0b68998

Browse files
CR Feedback: Ensure we exit CodeWriter.Read when destination is empty
1 parent 0f6e25c commit 0b68998

File tree

1 file changed

+6
-6
lines changed
  • src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration

1 file changed

+6
-6
lines changed

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration/CodeWriter.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,12 @@ public override int Read(char[] buffer, int index, int count)
435435

436436
foreach (var chunk in chunks)
437437
{
438+
if (destination.IsEmpty)
439+
{
440+
// If we have no more space in the destination, we're done.
441+
break;
442+
}
443+
438444
var source = chunk.Span;
439445

440446
// Slice if the first chunk is partial. Note that this only occurs for the first chunk.
@@ -470,12 +476,6 @@ public override int Read(char[] buffer, int index, int count)
470476
destination = destination[source.Length..];
471477

472478
charsWritten += source.Length;
473-
474-
// Break if we are done writing. chunkIndex and charIndex should have their correct values at this point.
475-
if (destination.IsEmpty)
476-
{
477-
break;
478-
}
479479
}
480480

481481
if (destination.IsEmpty)

0 commit comments

Comments
 (0)