Fix NPE caused by handling GetFileSize return value.

FileBackedVector wasn't properly checking the return value of
GetFileSize when deciding whether or not it needed to grow the
underlying file and remap. If GetFileSize failed due to an IO error,
then FileBackedVector would conclude (incorrectly) that growing wasn't
necessary and would attempt to access the mmapping at the requested
index - which could result in either an NPE (if the vector was empty) or
an invalid memory access (if the requested index exceeded the actual
size of the mmapping). See b/232273174#comment44 for more details.

This is a cherrypick of cl/451040413.

Test: Builds
Change-Id: I7ae0e3119126483c23a85dae3bd7a84712357209
2 files changed
tree: 906cf33f470d68add3cb0cc809ea250d42c88ec7
  1. icing/
  2. java/
  3. nativeLib/
  4. proto/
  5. .gitignore
  6. Android.bp
  7. AndroidManifest.xml
  8. build.gradle
  9. CMakeLists.txt
  10. CONTRIBUTING.md
  11. LICENSE
  12. METADATA
  13. MODULE_LICENSE_APACHE2
  14. OWNERS
  15. README.md
  16. synced_AOSP_CL_number.txt
  17. TEST_MAPPING
README.md

Icing Search Library

Icing is a fast, embedded, mobile-friendly full-text-search library written in C++.

This is not an officially supported Google product.