We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b96205d commit 72dec0bCopy full SHA for 72dec0b
src/DotNext/Buffers/BufferWriterSlim.cs
@@ -309,7 +309,13 @@ public bool TryDetachBuffer(out MemoryOwner<T> owner)
309
public MemoryOwner<T> DetachOrCopyBuffer()
310
{
311
MemoryOwner<T> result;
312
- if (NoOverflow)
+
313
+ if (position is 0)
314
+ {
315
+ result = default;
316
+ goto exit;
317
+ }
318
+ else if (NoOverflow)
319
320
result = allocator.AllocateExactly(position);
321
initialBuffer.CopyTo(result.Span);
@@ -319,9 +325,11 @@ public MemoryOwner<T> DetachOrCopyBuffer()
325
result = extraBuffer;
326
extraBuffer = default;
327
}
322
-
328
323
329
result.Truncate(position);
324
330
position = 0;
331
332
+ exit:
333
return result;
334
335
0 commit comments