cppcheck: Array index is used before limits check

Change-Id: I30154dd9504b70dc3212af3ac1d88dfc9a9d8396