Merge pull request #6991 from sfc-gh-etschannen/fix-recovery-version

fix: when more tlogs are absent than the replication factor we would access invalid memory
This commit is contained in:
Steve Atherton 2022-04-29 14:00:15 -07:00 committed by GitHub
commit 2887429f42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -1908,7 +1908,7 @@ Optional<std::tuple<Version, Version, std::vector<TLogLockResult>>> TagPartition
int absent = logSet->logServers.size() - results.size();
int safe_range_begin = logSet->tLogWriteAntiQuorum;
int new_safe_range_begin = std::min(logSet->tLogWriteAntiQuorum, (int)(results.size() - 1));
int safe_range_end = logSet->tLogReplicationFactor - absent;
int safe_range_end = std::max(logSet->tLogReplicationFactor - absent, 1);
if (!lastEnd.present() || ((safe_range_end > 0) && (safe_range_end - 1 < results.size()) &&
results[safe_range_end - 1].end < lastEnd.get())) {