mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 11:55:31 -04:00
universal7885: fm-aidl: MiddleState: Bounds checking
we need at least 2 elements on the vector. If it doesn't meet the requirements, return nullptr to keep it as-is unmodified.
This commit is contained in:
parent
225466e775
commit
ec1db378bd
1 changed files with 6 additions and 0 deletions
|
|
@ -3,6 +3,12 @@
|
|||
middlestate_t *saveMiddleState(const int value, const std::vector<int> &vec)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
// Bounds checking, we need at least 2 elements on the vector.
|
||||
// If it doesn't meet the requirements, return nullptr to keep it
|
||||
// as-is.
|
||||
if (vec.size() <= 1) return nullptr;
|
||||
|
||||
for (i = 0; i < vec.size() - 1; i++) {
|
||||
const int first = vec[i] - value;
|
||||
const int second = vec[i + 1] - value;
|
||||
|
|
|
|||
Loading…
Reference in a new issue