Fix memory leak in FakeSSLCertificate::GetChain(), discovered by Linux Memcheck build/try bots.

TBR=hellner
BUG=

Review URL: https://webrtc-codereview.appspot.com/18969004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6809 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
solenberg@webrtc.org 2014-08-01 10:07:46 +00:00
parent 1a678c61f1
commit 42d65ce8d7

View File

@ -82,6 +82,7 @@ class FakeSSLCertificate : public talk_base::SSLCertificate {
std::vector<SSLCertificate*> new_certs(certs_.size());
std::transform(certs_.begin(), certs_.end(), new_certs.begin(), DupCert);
*chain = new SSLCertChain(new_certs);
std::for_each(new_certs.begin(), new_certs.end(), DeleteCert);
return true;
}
@ -89,6 +90,7 @@ class FakeSSLCertificate : public talk_base::SSLCertificate {
static FakeSSLCertificate* DupCert(FakeSSLCertificate cert) {
return cert.GetReference();
}
static void DeleteCert(SSLCertificate* cert) { delete cert; }
std::string data_;
std::vector<FakeSSLCertificate> certs_;
std::string digest_algorithm_;