From 070b42da93c805fb7577f88ed4bfe03baf08b95e Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Mon, 29 Jul 2013 19:46:52 +0300 Subject: [PATCH] Bug 892588 - crash in nsNSSASN1Sequence::~nsNSSASN1Sequence, r=bsmith --HG-- extra : rebase_source : a3d1a29f0ebcfb05462be3a46b38b7be08163379 --- security/manager/ssl/src/nsNSSASN1Object.h | 4 ++-- security/manager/ssl/src/nsNSSCertHelper.cpp | 8 ++++---- security/manager/ssl/src/nsNSSCertificate.cpp | 20 ++++++++----------- security/manager/ssl/src/nsNSSCertificate.h | 3 +-- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/security/manager/ssl/src/nsNSSASN1Object.h b/security/manager/ssl/src/nsNSSASN1Object.h index 24901b1e5fe7..812703a3b5a1 100644 --- a/security/manager/ssl/src/nsNSSASN1Object.h +++ b/security/manager/ssl/src/nsNSSASN1Object.h @@ -20,7 +20,7 @@ class nsNSSASN1Sequence : public nsIASN1Sequence { public: - NS_DECL_THREADSAFE_ISUPPORTS + NS_DECL_ISUPPORTS NS_DECL_NSIASN1SEQUENCE NS_DECL_NSIASN1OBJECT @@ -40,7 +40,7 @@ private: class nsNSSASN1PrintableItem : public nsIASN1PrintableItem { public: - NS_DECL_THREADSAFE_ISUPPORTS + NS_DECL_ISUPPORTS NS_DECL_NSIASN1PRINTABLEITEM NS_DECL_NSIASN1OBJECT diff --git a/security/manager/ssl/src/nsNSSCertHelper.cpp b/security/manager/ssl/src/nsNSSCertHelper.cpp index 5ac9c072cc9f..876d5d202511 100644 --- a/security/manager/ssl/src/nsNSSCertHelper.cpp +++ b/security/manager/ssl/src/nsNSSCertHelper.cpp @@ -2110,7 +2110,7 @@ nsNSSCertificate::CreateTBSCertificateASN1Struct(nsIASN1Sequence **retSequence, } nsresult -nsNSSCertificate::CreateASN1Struct() +nsNSSCertificate::CreateASN1Struct(nsIASN1Object** aRetVal) { nsNSSShutDownPreventionLock locker; if (isAlreadyShutDown()) @@ -2118,14 +2118,14 @@ nsNSSCertificate::CreateASN1Struct() nsCOMPtr sequence = new nsNSSASN1Sequence(); - mASN1Structure = sequence; - nsCOMPtr asn1Objects; sequence->GetASN1Objects(getter_AddRefs(asn1Objects)); nsXPIDLCString title; GetWindowTitle(getter_Copies(title)); - mASN1Structure->SetDisplayName(NS_ConvertUTF8toUTF16(title)); + sequence->SetDisplayName(NS_ConvertUTF8toUTF16(title)); + *aRetVal = sequence.forget().get(); + // This sequence will be contain the tbsCertificate, signatureAlgorithm, // and signatureValue. nsresult rv; diff --git a/security/manager/ssl/src/nsNSSCertificate.cpp b/security/manager/ssl/src/nsNSSCertificate.cpp index ea1636357f60..5b839ff7097d 100644 --- a/security/manager/ssl/src/nsNSSCertificate.cpp +++ b/security/manager/ssl/src/nsNSSCertificate.cpp @@ -1372,19 +1372,15 @@ nsNSSCertificate::GetASN1Structure(nsIASN1Object * *aASN1Structure) nsNSSShutDownPreventionLock locker; nsresult rv = NS_OK; NS_ENSURE_ARG_POINTER(aASN1Structure); - if (!mASN1Structure) { - // First create the recursive structure os ASN1Objects - // which tells us the layout of the cert. - rv = CreateASN1Struct(); - if (NS_FAILED(rv)) { - return rv; - } -#ifdef DEBUG_javi - DumpASN1Object(mASN1Structure, 0); -#endif + // First create the recursive structure os ASN1Objects + // which tells us the layout of the cert. + rv = CreateASN1Struct(aASN1Structure); + if (NS_FAILED(rv)) { + return rv; } - *aASN1Structure = mASN1Structure; - NS_IF_ADDREF(*aASN1Structure); +#ifdef DEBUG_javi + DumpASN1Object(*aASN1Structure, 0); +#endif return rv; } diff --git a/security/manager/ssl/src/nsNSSCertificate.h b/security/manager/ssl/src/nsNSSCertificate.h index cdf52850adff..e4e3f3430e80 100644 --- a/security/manager/ssl/src/nsNSSCertificate.h +++ b/security/manager/ssl/src/nsNSSCertificate.h @@ -60,8 +60,7 @@ private: mozilla::ScopedCERTCertificate mCert; bool mPermDelete; uint32_t mCertType; - nsCOMPtr mASN1Structure; - nsresult CreateASN1Struct(); + nsresult CreateASN1Struct(nsIASN1Object** aRetVal); nsresult CreateTBSCertificateASN1Struct(nsIASN1Sequence **retSequence, nsINSSComponent *nssComponent); nsresult GetSortableDate(PRTime aTime, nsAString &_aSortableDate);