Skip to content

Commit

Permalink
Dispose IDisposables in NativePdbWriter
Browse files Browse the repository at this point in the history
- The code creates a local variable that's an IDisposable
  (CustomMetadataWriter), but doesn't call Dispose() on it.

- The CustomMetadataWriter class holds two IDisposables (MemoryStream
  and BinaryStreamWriter), but was only Dispose()ing one of them.
  • Loading branch information
omajid committed Jun 20, 2024
1 parent 1da2145 commit 2afc92b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion symbols/pdb/Mono.Cecil.Pdb/NativePdbWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void Write (MethodDebugInformation info)

void DefineCustomMetadata (MethodDebugInformation info, MetadataToken import_parent)
{
var metadata = new CustomMetadataWriter (this.writer);
using var metadata = new CustomMetadataWriter (this.writer);

if (import_parent.RID != 0) {
metadata.WriteForwardInfo (import_parent);
Expand Down Expand Up @@ -367,6 +367,7 @@ public void WriteCustomMetadata ()
public void Dispose ()
{
stream.Dispose ();
writer.Dispose ();
}
}
}

0 comments on commit 2afc92b

Please sign in to comment.