Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Potential NPE: missing non-null contract for Context in BaseFilterRender.initGl

Aperta
#2,207 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
android, java, kotlin
Ambito
mobile-dev

Direzione di ricerca

Read the cited CropFilterRender.kt, BaseFilterRender.java, and GlUtil.java code, then trace the BaseFilterRender.initGl call sites to determine whether null can reach the filter. Confirm the intended Context contract and, if needed, add a regression test for the initialization path; done means the contract is explicit and the behavior is covered.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

During a source-level review, I found a potential Kotlin–Java nullability issue in CropFilterRender.

CropFilterRender.initGlFilter declares its parameter as nullable (Context?) and passes it directly to the Java method GlUtil.getStringFromRaw(Context context). That Java method immediately calls context.getResources() without checking for null.

Relevant code:

CropFilterRender.kt#L65-L67
BaseFilterRender.java#L46-L66
GlUtil.java#L100-L104

If a null value reaches this call path, context.getResources() can throw a NullPointerException.

I have not reproduced this exception in an Android instrumentation test yet. The normal rendering path appears to initialize MainRender with a non-null Context, so I would appreciate confirmation of the intended nullability contract.

To Reproduce

This report was prepared against RootEncoder commit ebb9b4b0cc5c54d58efbd18a760ca5b7e50d3fc7.

  1. Inspect CropFilterRender.initGlFilter(context: Context?).
  2. Observe that the nullable value is passed to GlUtil.getStringFromRaw.
  3. Observe that GlUtil.getStringFromRaw calls context.getResources() without a null check.
  4. Please confirm whether Context is guaranteed to be non-null whenever BaseFilterRender.initGl is called.

No direct initGlFilter(null) call was found in the repository. However, BaseFilterRender.initGl(...) is public, its Java Context parameter has no @NonNull annotation, and the nullability contract is not explicit.

Expected behavior

The nullability contract should be explicit:

If Context must always be non-null, the Java parameters should be annotated as non-null and the Kotlin override should use Context instead of Context?.
If null is a valid input, the code should handle it before calling GlUtil.getStringFromRaw.

Screenshots

Not applicable. This is a source-level nullability finding.

Smartphone (please complete the following information)

Library version: 2.8.1
Source commit: ebb9b4b0cc5c54d58efbd18a760ca5b7e50d3fc7
Device: Not reproduced on a device yet
OS: Not reproduced on a device yet
Media server: Not applicable
Class used: CropFilterRender / BaseFilterRender

Additional context

The normal internal rendering path appears to provide a non-null Context, but the public initialization contract does not make this requirement explicit.

A possible fix is to:

Add @NonNull to the Java filter initialization parameters.
Change CropFilterRender.initGlFilter to accept Context.
Store the MainRender context as a non-null initialized value.
Add a regression test covering the filter initialization path.

Could you please clarify whether this should be considered:

  1. a confirmed bug,
  2. an intentional non-null contract,
  3. a false positive, or
  4. a case that requires a specific Android/GL lifecycle to reproduce?
Lingua principale
Kotlin
Stelle
3k
Fork
946
Merge medio
3g 17h
PR unite (30g)
9

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pedroSG94/RootEncoder

Tutte le issue di pedroSG94/RootEncoder

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.