Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b66d04b0 authored by Greg Kaiser's avatar Greg Kaiser
Browse files

AChoreographer: Avoid potential NULL dereference

We move our nullptr check to before our dereference of the pointer.

Test: TreeHugger
Bug: 154874011
Change-Id: If1e51b8fb88f72b6b4cbda52543bf093e6c76ca9
parent 7bcb8931
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -250,12 +250,12 @@ void Choreographer::registerRefreshRateCallback(AChoreographer_refreshRateCallba
    }
    if (needsRegistration) {
        JNIEnv* env = getJniEnv();
        jobject dmg = env->CallStaticObjectMethod(gJni.displayManagerGlobal.clazz,
                                                  gJni.displayManagerGlobal.getInstance);
        if (env == nullptr) {
            ALOGW("JNI environment is unavailable, skipping registeration");
            ALOGW("JNI environment is unavailable, skipping registration");
            return;
        }
        jobject dmg = env->CallStaticObjectMethod(gJni.displayManagerGlobal.clazz,
                                                  gJni.displayManagerGlobal.getInstance);
        if (dmg == nullptr) {
            ALOGW("DMS is not initialized yet: skipping registration");
            return;