Commit 350b2ee1 authored by Matt Mueller's avatar Matt Mueller Committed by Commit Bot

Make CertPathBuilder::Result movable, remove Clear method.

The Clear should have cleared exceeded_iteration_limit and exceeded_deadline,
but it was overlooked. Instead of using a Clear method, the object can be reset
by assigning a default-constructed Result(). This removes the need to
update Clear any time new members are added.

(The lack of clearing those members did not cause any issues with the way they
are currently used in chromium, so this shouldn't cause any behavioral changes.)

Bug: 410574
Change-Id: I3585abed17bfdeaf1362ee098ebddfdf2c2d3080
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1730957
Commit-Queue: Matt Mueller <mattm@chromium.org>
Reviewed-by: default avatarRyan Sleevi <rsleevi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683306}
parent 97100c4b
...@@ -439,7 +439,7 @@ void TryBuildPath(const scoped_refptr<ParsedCertificate>& target, ...@@ -439,7 +439,7 @@ void TryBuildPath(const scoped_refptr<ParsedCertificate>& target,
if (!der::EncodeTimeAsGeneralizedTime(verification_time, if (!der::EncodeTimeAsGeneralizedTime(verification_time,
&der_verification_time)) { &der_verification_time)) {
// This shouldn't be possible. // This shouldn't be possible.
result->Clear(); *result = CertPathBuilder::Result();
return; return;
} }
......
...@@ -507,7 +507,9 @@ bool CertPathBuilderResultPath::IsValid() const { ...@@ -507,7 +507,9 @@ bool CertPathBuilderResultPath::IsValid() const {
} }
CertPathBuilder::Result::Result() = default; CertPathBuilder::Result::Result() = default;
CertPathBuilder::Result::Result(Result&&) = default;
CertPathBuilder::Result::~Result() = default; CertPathBuilder::Result::~Result() = default;
CertPathBuilder::Result& CertPathBuilder::Result::operator=(Result&&) = default;
bool CertPathBuilder::Result::HasValidPath() const { bool CertPathBuilder::Result::HasValidPath() const {
return GetBestValidPath() != nullptr; return GetBestValidPath() != nullptr;
...@@ -534,11 +536,6 @@ CertPathBuilder::Result::GetBestPathPossiblyInvalid() const { ...@@ -534,11 +536,6 @@ CertPathBuilder::Result::GetBestPathPossiblyInvalid() const {
return paths[best_result_index].get(); return paths[best_result_index].get();
} }
void CertPathBuilder::Result::Clear() {
paths.clear();
best_result_index = 0;
}
CertPathBuilder::CertPathBuilder( CertPathBuilder::CertPathBuilder(
scoped_refptr<ParsedCertificate> cert, scoped_refptr<ParsedCertificate> cert,
TrustStore* trust_store, TrustStore* trust_store,
...@@ -560,7 +557,7 @@ CertPathBuilder::CertPathBuilder( ...@@ -560,7 +557,7 @@ CertPathBuilder::CertPathBuilder(
initial_any_policy_inhibit_(initial_any_policy_inhibit), initial_any_policy_inhibit_(initial_any_policy_inhibit),
out_result_(result) { out_result_(result) {
DCHECK(delegate); DCHECK(delegate);
result->Clear(); *result = Result();
// The TrustStore also implements the CertIssuerSource interface. // The TrustStore also implements the CertIssuerSource interface.
AddCertIssuerSource(trust_store); AddCertIssuerSource(trust_store);
} }
......
...@@ -106,7 +106,9 @@ class NET_EXPORT CertPathBuilder { ...@@ -106,7 +106,9 @@ class NET_EXPORT CertPathBuilder {
// were attempted. // were attempted.
struct NET_EXPORT Result { struct NET_EXPORT Result {
Result(); Result();
Result(Result&&);
~Result(); ~Result();
Result& operator=(Result&&);
// Returns true if there was a valid path. // Returns true if there was a valid path.
bool HasValidPath() const; bool HasValidPath() const;
...@@ -118,9 +120,6 @@ class NET_EXPORT CertPathBuilder { ...@@ -118,9 +120,6 @@ class NET_EXPORT CertPathBuilder {
// Returns the best CertPathBuilderResultPath or nullptr if there was none. // Returns the best CertPathBuilderResultPath or nullptr if there was none.
const CertPathBuilderResultPath* GetBestPathPossiblyInvalid() const; const CertPathBuilderResultPath* GetBestPathPossiblyInvalid() const;
// Resets to the initial value.
void Clear();
// List of paths that were attempted and the result for each. // List of paths that were attempted and the result for each.
std::vector<std::unique_ptr<CertPathBuilderResultPath>> paths; std::vector<std::unique_ptr<CertPathBuilderResultPath>> paths;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment