Avoid out of range exception
When osRelease is x.y.z without any suffix, substr(npos) will
throw an exception. Check before checking the suffix.
Test: libvintf_test
Fixes: 153525360
Change-Id: Ia6d4dbdf0dd704edc6df327072092a3d30162d80
diff --git a/RuntimeInfo-target.cpp b/RuntimeInfo-target.cpp
index 8889b03..659cdec 100644
--- a/RuntimeInfo-target.cpp
+++ b/RuntimeInfo-target.cpp
@@ -148,6 +148,7 @@
return UNKNOWN_ERROR;
}
mRuntimeInfo->mIsMainline =
+ pos != std::string::npos &&
android::base::StartsWith(mRuntimeInfo->mOsRelease.substr(pos), kMainline);
return OK;
}