iron-software / IronSoftware.System.Drawing

An open-source System.Drawing.Common replacement for .NET 5 and above on all platforms. Bringing together System.Drawing, Maui, and ImageSharp's Bitmap, Image, Font, and Shape types via an agnostic free NuGet package.
Other
114 stars 18 forks source link

Fix null reference exception in AnyBitmap.Dispose method #54

Closed artem-iron closed 1 year ago

artem-iron commented 1 year ago

Fix null reference exception in AnyBitmap.Dispose method

Description

This PR adds a null check for AnyBitmap.Image private property in AnyBitmap.Dispose method before calling Image.Dispose(). I've also taken this opportunity to perform a code cleanup in AnyBitmap class, to make it slightly more readable. Still needs work, particularly in naming conventions department (method parameters are in PascalCase which creates lots of confusion).

Type of change

How Has This Been Tested?

100% of existing tests pass locally

Checklist:

Additional Context

Hard to design unit tests for the issue being tested, too tight race condition fails inside of the Image object.