Skip to content

#20 Refactor - Declare "lottie" as nullable#21

Open
young924 wants to merge 3 commits intothorvg:mainfrom
young924:feature/refactor-nullable-lottie
Open

#20 Refactor - Declare "lottie" as nullable#21
young924 wants to merge 3 commits intothorvg:mainfrom
young924:feature/refactor-nullable-lottie

Conversation

@young924
Copy link
Collaborator

@young924 young924 commented Dec 7, 2025

Screenshot 2025-12-07 at 7 16 36 PM

issue #20

@young924 young924 requested review from hermet and ol-of as code owners December 7, 2025 10:55
length: Int,
outValues: IntArray?
): Long

Copy link
Collaborator

@ol-of ol-of Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since content and outValues are nullable, the current implementation of
Java_org_thorvg_lottie_LottieDrawable_nCreateLottie in lottie-libs.cpp can crash because it does not perform any null checks.

Please add null-safety checks to Java_org_thorvg_lottie_LottieDrawable_nCreateLottie, for example:

extern "C" jlong
Java_org_thorvg_lottie_LottieDrawable_nCreateLottie(JNIEnv *env, jclass clazz,
        jstring content, jint length, jintArray out_values) {
    if (content == nullptr || inputStr == nullptr) {
        return 0;
    }
   ...
}

Copy link
Collaborator

@ol-of ol-of left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve left comments regarding the parts that could potentially cause a crash.
For now, please either revert the changes to nCreateLottie or add proper null-checks (NPE handling) in Java_org_thorvg_lottie_LottieDrawable_nCreateLottie.

@hermet hermet added the refactoring Code refactoring label Dec 9, 2025
@young924
Copy link
Collaborator Author

young924 commented Dec 10, 2025

I’ve left comments regarding the parts that could potentially cause a crash. For now, please either revert the changes to nCreateLottie or add proper null-checks (NPE handling) in Java_org_thorvg_lottie_LottieDrawable_nCreateLottie.

I added null-safety checks to Java_org_thorvg_lottie_LottieDrawable_nCreateLottie
Thank you for your comment! @ol-of

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants