Fix potential crash when getSensorList returns error

bug: b/19937981

Change-Id: Ibfb8c625609923b4e60fa73685dbeb10944ab2b9
This commit is contained in:
Peng Xu
2016-02-04 22:27:20 -08:00
parent 73ebd130eb
commit a08c9f52db

View File

@@ -205,8 +205,8 @@ nativeGetSensorAtIndex(JNIEnv *env, jclass clazz, jlong sensorManager, jobject s
SensorManager* mgr = reinterpret_cast<SensorManager*>(sensorManager);
Sensor const* const* sensorList;
size_t count = mgr->getSensorList(&sensorList);
if (size_t(index) >= count) {
ssize_t count = mgr->getSensorList(&sensorList);
if (ssize_t(index) >= count) {
return false;
}