Add length guard to fix Windows build with VS2019 16.11.7 headers (flutter/engine#30189)

The shell tests are failing on Windows against the latest VS2019 headers due to a new safety assert.
This commit is contained in:
Brandon DeRosier
2021-12-07 13:28:39 -08:00
committed by GitHub
parent 31e0da7a30
commit 68fde39542

View File

@@ -171,7 +171,8 @@ static bool IsAllowedDartVMFlag(const std::string& flag) {
// Check that the prefix of the flag matches one of the allowed flags.
// We don't need to worry about cases like "--safe --sneaky_dangerous" as
// the VM will discard these as a single unrecognized flag.
if (std::equal(allowed.begin(), allowed.end(), flag.begin())) {
if (flag.length() >= allowed.length() &&
std::equal(allowed.begin(), allowed.end(), flag.begin())) {
return true;
}
}