Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 6, 2025

Fixes #14113

Proposed changes

  • Added coordinate clipping in FillRectangle, FillRectangles, and DrawImage overloads to prevent GDI+ out-of-bounds writes when using SmoothingMode.AntiAlias with PixelFormat.Format24bppRgb
  • When drawing outside bitmap bounds with this specific combination, coordinates are now clipped to valid ranges before calling GDI+
  • Rectangles completely outside bounds are skipped; partially out-of-bounds rectangles are clipped to the intersection

Customer Impact

  • Prevents ExecutionEngineException (fatal process crash in .NET 9+) and AccessViolationException (.NET 8) when drawing with antialiasing on 24bpp RGB bitmaps
  • Applications using this specific combination will now continue running instead of crashing

Regression?

  • No

Risk

  • Low. Change only affects the specific problematic combination (AntiAlias + Format24bppRgb + out-of-bounds drawing). Other scenarios pass through unchanged.

Test methodology

Test environment(s)

  • .NET 9.0
  • Windows 11

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Microsoft Reviewers: Open in CodeFlow

Copilot AI changed the title [WIP] Fix GDI+ crash in FillRectangle with AntiAlias and 24bppRgb Fix GDI+ crash in FillRectangle with AntiAlias and 24bppRgb Dec 6, 2025
Copilot finished work on behalf of KlausLoeffelmann December 6, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants