Merge "Fix unsigned integer overflow of i, which gives SIGABRT" am: 8db23af93b am: 1886fb446c am: 50b893ed6a
Change-Id: I98b2edd992c56bf2242258d7d137cf4d2f90df9d
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index 6d1d58a..2ef0393 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -1092,7 +1092,9 @@
return FS_MGR_MNTALL_FAIL;
}
- for (size_t i = 0; i < fstab->size(); i++) {
+ // Keep i int to prevent unsigned integer overflow from (i = top_idx - 1),
+ // where top_idx is 0. It will give SIGABRT
+ for (int i = 0; i < static_cast<int>(fstab->size()); i++) {
auto& current_entry = (*fstab)[i];
// If a filesystem should have been mounted in the first stage, we