Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: SymWriter COM object is not released on exception #955

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions symbols/pdb/Mono.Cecil.Pdb/NativePdbWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ public void Write ()

public void Dispose ()
{
writer.Close ();
}
}

Expand Down
5 changes: 5 additions & 0 deletions symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ static extern int CoCreateInstance (

readonly ISymUnmanagedWriter2 writer;
readonly Collection<ISymUnmanagedDocumentWriter> documents;
bool closed = false;

public SymWriter ()
{
Expand Down Expand Up @@ -78,6 +79,10 @@ public void DefineConstant2 (string name, object value, int sigToken)

public void Close ()
{
if (closed)
return;

closed = true;
writer.Close ();
Marshal.ReleaseComObject (writer);

Expand Down