The earlier patch 3cf7b3c59 introduced a stability regression. Perform the appropriate bounds checking alongside the fix it implements. Bug 8264185 Change-Id: I943d6c05bacdd777f89243fdac97788b16639dc6