Skip to content

Commit 0cf3f74

Browse files
committed
Dispose objects in PayloadWriter.
These objects implement IDisposable and trigger (false positive) analysis warnings about undisposed objects. PayloadWriter should not be made IDisposable because it could be rewritten to use ArrayPool (and manage its own memory); clients don't need to worry about this implementation detail.
1 parent d518c8c commit 0cf3f74

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/MySqlConnector/Serialization/PayloadWriter.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.IO;
33
using System.Text;
44

@@ -53,7 +53,9 @@ public void WriteNullTerminatedString(string value)
5353
public byte[] ToBytes()
5454
{
5555
m_writer.Flush();
56-
return m_stream.ToArray();
56+
using (m_writer)
57+
using (m_stream)
58+
return m_stream.ToArray();
5759
}
5860

5961
readonly MemoryStream m_stream;

0 commit comments

Comments
 (0)