fix: when more tlogs are absent than the replication factor we would access invalid memory

This commit is contained in:
Evan Tschannen 2022-04-27 16:53:30 -07:00
parent 79063d5fc4
commit a825eb8a8c

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())) {