Fix a typo which could cause a buffer overflow in the light sensor HAL
Change-Id: I9231e26b423bfc47a4564c24895d19c2c5a2c00f
diff --git a/libsensors/LightSensor.cpp b/libsensors/LightSensor.cpp
index fa04d04..119978e 100644
--- a/libsensors/LightSensor.cpp
+++ b/libsensors/LightSensor.cpp
@@ -147,8 +147,8 @@
640.0, 1280.0, 2600.0, 10240.0
};
- const size_t arraySize = sizeof(luxValues)/sizeof(*luxValues);
- if (index >= arraySize)
- index = arraySize;
+ const size_t maxIndex = sizeof(luxValues)/sizeof(*luxValues) - 1;
+ if (index > maxIndex)
+ index = maxIndex;
return luxValues[index];
}