Index: net/quic/crypto/common_cert_set.cc |
diff --git a/net/quic/crypto/common_cert_set.cc b/net/quic/crypto/common_cert_set.cc |
index 78aa9276197b303f54e427f7ca31b2ac37f62945..ee1ac67dcf7b8dfef7c60e3ba4b8578ebbeff213 100644 |
--- a/net/quic/crypto/common_cert_set.cc |
+++ b/net/quic/crypto/common_cert_set.cc |
@@ -53,17 +53,17 @@ StringPiece CommonCertSetsQUIC::GetCommonHashes() const { |
} |
StringPiece CommonCertSetsQUIC::GetCert(uint64 hash, uint32 index) const { |
+ StringPiece cert; |
for (size_t i = 0; i < arraysize(kSets); i++) { |
if (kSets[i].hash == hash) { |
- if (index >= kSets[i].num_certs) { |
- return StringPiece(); |
+ if (index < kSets[i].num_certs) { |
+ cert.set(kSets[i].certs[index], kSets[i].lens[index]); |
} |
- return StringPiece(reinterpret_cast<const char*>(kSets[i].certs[index]), |
- kSets[i].lens[index]); |
+ break; |
} |
} |
- return StringPiece(); |
+ return cert; |
} |
// Compare returns a value less than, equal to or greater than zero if |a| is |
@@ -110,11 +110,7 @@ bool CommonCertSetsQUIC::MatchCert(StringPiece cert, |
// Binary search for a matching certificate. |
size_t min = 0; |
size_t max = kSets[j].num_certs - 1; |
- for (;;) { |
- if (max < min) { |
- break; |
- } |
- |
+ while (max >= min) { |
size_t mid = min + ((max - min) / 2); |
int n = Compare(cert, kSets[j].certs[mid], kSets[j].lens[mid]); |
if (n < 0) { |