Skip to content

Handle null GIF input with IOException - #2217

Merged
pedroSG94 merged 1 commit into
pedroSG94:masterfrom
blihio:codex/gif-null-input
Oct 17, 2026
Merged

pedroSG94 merged 1 commit into
pedroSG94:masterfrom
blihio:codex/gif-null-input

Conversation

@blihio

@blihio blihio commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Problem

GifFilterRender.setGif accepts InputStream?, but GifStreamObject.load immediately calls available() on it. Passing null therefore raises an unexpected NullPointerException before GIF decoding starts.

Change

Reject null at the start of GifStreamObject.load with IOException, using the existing GIF loading error path. This preserves the Kotlin nullable parameter and existing JVM method signatures.

Add GifFilterRenderTest.nullInputIsReportedAsIoException to exercise the public Kotlin API. It fails with NPE on the original code and passes after this fix.

Validation

With only this change applied to base commit 82a9cb4ee4babdc792d2ccee8b893f2b36207d40, using Gradle 9.7.1 and JDK 17:

./gradlew :common:testDebugUnitTest :encoder:testDebugUnitTest
  • common: 98 tests passed.
  • encoder: 26 tests passed.
  • git diff --check passed.

A supplementary JVM check also loaded a valid one-frame 1×1 GIF using the real decoder before and after the fix. That check uses an in-memory Android Bitmap stand-in; device rendering was not tested.

Fixes #2216

@pedroSG94
pedroSG94 merged commit 046710c into pedroSG94:master Oct 17, 2026
1 check passed
@pedroSG94

Copy link
Copy Markdown
Owner

Thank you for the PR. Merged

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.

Nullable GIF input causes NullPointerException in GifStreamObject.load

2 participants