Skip to content

Fix the leak of RGBA buffer when WebPDecode failed#122

Merged
dreampiggy merged 1 commit into
SDWebImage:masterfrom
therehello:bugfix_decode_rgba_leak
Jul 20, 2026
Merged

Fix the leak of RGBA buffer when WebPDecode failed#122
dreampiggy merged 1 commit into
SDWebImage:masterfrom
therehello:bugfix_decode_rgba_leak

Conversation

@therehello

@therehello therehello commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Also fix the unbalanced #if SD_MAC braces which broke the macOS test compile.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed a memory leak that could occur when decoding invalid or unsupported WebP image data.
  • Tests

    • Corrected platform-specific test conditions to ensure WebP decoding behavior is validated consistently across supported environments.

Also fix the unbalanced #if SD_MAC braces which broke the macOS test compile.
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e47b5f4d-98f7-4698-89ee-1b13ba2e0f72

📥 Commits

Reviewing files that changed from the base of the PR and between 12d83ed and 74b78eb.

📒 Files selected for processing (2)
  • SDWebImageWebPCoder/Classes/SDImageWebPCoder.m
  • Tests/SDWebImageWebPCoderTests.m

📝 Walkthrough

Walkthrough

The WebP decoder now frees its RGBA buffer when WebPDecode fails. The related test adjusts conditional compilation boundaries so its runtime fallback is outside the SD_MAC block.

Changes

WebP decode maintenance

Layer / File(s) Summary
Release RGBA buffer on decode failure
SDWebImageWebPCoder/Classes/SDImageWebPCoder.m
The WebPDecode failure branch calls WebPFree(rgba) before returning nil.
Correct test conditional scope
Tests/SDWebImageWebPCoderTests.m
The SD_MAC conditional block now ends before the runtime else fallback in the WebP decode test.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing the RGBA buffer leak on WebPDecode failure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dreampiggy
dreampiggy merged commit 5f80930 into SDWebImage:master Jul 20, 2026
1 of 3 checks passed
@dreampiggy dreampiggy added the leak Memory Leak label Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

leak Memory Leak

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants