EventLog: Check for exception after add()

When reading events, calling Collection.add() may result in an
OutOfMemoryError or immutability error. Check for an exception
after the call in EventLog and SecurityLog.

Bug: 67511924
Test: m
Test: Device boots
Change-Id: If0fbf6b01051b5311eeb88d3f52470cd8b1eec59
This commit is contained in:
Andreas Gampe
2017-10-09 08:25:36 -07:00
parent ed8d236319
commit ca06d8b5ad
2 changed files with 6 additions and 0 deletions

View File

@@ -186,6 +186,9 @@ static void readEvents(JNIEnv* env, int loggerMode, jlong startTime, jobject out
env->CallBooleanMethod(out, gCollectionAddID, event);
env->DeleteLocalRef(event);
env->DeleteLocalRef(array);
if (env->ExceptionCheck() == JNI_TRUE) {
break;
}
}
android_logger_list_close(logger_list);

View File

@@ -215,6 +215,9 @@ static void readEvents(JNIEnv* env, int loggerMode, jintArray tags, jlong startT
env->CallBooleanMethod(out, gCollectionAddID, event);
env->DeleteLocalRef(event);
env->DeleteLocalRef(array);
if (env->ExceptionCheck() == JNI_TRUE) {
break;
}
}
}