From 34b1289eb33a88631bbf8dc61febfe31ef3a9235 Mon Sep 17 00:00:00 2001 From: "rch@chromium.org" Date: Wed, 1 Aug 2012 22:02:33 +0000 Subject: [PATCH] Add a DCHECK to ECSignatureCreator::SetFactoryForTesting to help avoid use-after-free problems. Review URL: https://chromiumcodereview.appspot.com/10828118 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149506 0039d316-1c4b-4281-b951-d872f2087c98 --- crypto/ec_signature_creator.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crypto/ec_signature_creator.cc b/crypto/ec_signature_creator.cc index cbaa820cec9600..a6887bc117b7f5 100644 --- a/crypto/ec_signature_creator.cc +++ b/crypto/ec_signature_creator.cc @@ -4,6 +4,7 @@ #include "crypto/ec_signature_creator.h" +#include "base/logging.h" #include "crypto/ec_signature_creator_impl.h" namespace crypto { @@ -24,6 +25,9 @@ ECSignatureCreator* ECSignatureCreator::Create(ECPrivateKey* key) { // static void ECSignatureCreator::SetFactoryForTesting( ECSignatureCreatorFactory* factory) { + // We should always clear the factory after each test to avoid + // use-after-free problems. + DCHECK(!g_factory_ || !factory); g_factory_ = factory; }