Skip to content

Fix resource leak in SKImage.FromEncodedData(SKData, SKRectI)#3997

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-resource-leak-in-skimage
Draft

Fix resource leak in SKImage.FromEncodedData(SKData, SKRectI)#3997
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-resource-leak-in-skimage

Conversation

Copilot AI commented May 15, 2026

Copy link
Copy Markdown
Contributor

Description of Change

FromEncodedData(SKData, SKRectI) creates an intermediate SKImage then calls .Subset(), but never disposes the intermediate when Subset() returns a different instance. Applied the standard same-instance safety pattern:

var image = FromEncodedData(data);
if (image == null)
    return null;

var result = image.Subset(subset);
if (result != image)
    image.Dispose();

return result;

Bugs Fixed

API Changes

None.

Behavioral Changes

The intermediate image is now disposed when Subset() returns a new instance, preventing a native resource leak.

Required skia PR

None.

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Merged related skia PRs
  • Changes adhere to coding standard
  • Updated documentation

Tests omitted: existing SKImage tests cover this path; the fix is a mechanical application of the same-instance disposal pattern used throughout the codebase (e.g., ToRasterImage, other Subset call sites).

Copilot AI changed the title [WIP] Fix resource leak in SKImage.FromEncodedData due to undisposed intermediate image Fix resource leak in SKImage.FromEncodedData(SKData, SKRectI) May 15, 2026
Copilot AI requested a review from mattleibow May 15, 2026 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[fix-finder] Fix resource leak in SKImage.FromEncodedData(SKData, SKRectI) due to undisposed intermediate image

2 participants