AChoreographer: Avoid potential NULL dereference

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

Test: TreeHugger
Bug: 154874011
Change-Id: If1e51b8fb88f72b6b4cbda52543bf093e6c76ca9
This commit is contained in:
Greg Kaiser 2020-05-11 06:52:15 -07:00
parent 7bcb89317d
commit b66d04b0a2

View file

@ -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;