From 1cbc8808cdcaeeafe158187038df16fad96bcb7f Mon Sep 17 00:00:00 2001 From: "wtc%netscape.com" Date: Fri, 1 Aug 2003 02:02:47 +0000 Subject: [PATCH] Bugzilla bug 214695: fixed incorrect use of PR_AtomicDecrement on reference counts. The reference count should not be read "naked". Instead, we should simply use the return value of PR_AtomicDecrement for the result of the decrement. Modified Files: dev/devmod.c dev/devslot.c dev/devtoken.c pki/certificate.c pki/pkibase.c git-svn-id: svn://10.0.0.236/trunk@145445 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/security/nss/lib/dev/devmod.c | 5 ++--- mozilla/security/nss/lib/dev/devslot.c | 5 ++--- mozilla/security/nss/lib/dev/devtoken.c | 5 ++--- mozilla/security/nss/lib/pki/certificate.c | 5 ++--- mozilla/security/nss/lib/pki/pkibase.c | 5 ++--- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/mozilla/security/nss/lib/dev/devmod.c b/mozilla/security/nss/lib/dev/devmod.c index d4b69bc9e31..2983c111b7b 100644 --- a/mozilla/security/nss/lib/dev/devmod.c +++ b/mozilla/security/nss/lib/dev/devmod.c @@ -32,7 +32,7 @@ */ #ifdef DEBUG -static const char CVS_ID[] = "@(#) $RCSfile: devmod.c,v $ $Revision: 1.4 $ $Date: 2003-07-01 00:32:20 $ $Name: not supported by cvs2svn $"; +static const char CVS_ID[] = "@(#) $RCSfile: devmod.c,v $ $Revision: 1.5 $ $Date: 2003-08-01 02:02:43 $ $Name: not supported by cvs2svn $"; #endif /* DEBUG */ #ifndef NSSCKEPV_H @@ -714,8 +714,7 @@ nssModule_Destroy ( ) { PRUint32 i, numSlots; - PR_AtomicDecrement(&mod->base.refCount); - if (mod->base.refCount == 0) { + if (PR_AtomicDecrement(&mod->base.refCount) == 0) { if (mod->numSlots == 0) { (void)nssModule_Unload(mod); return nssArena_Destroy(mod->base.arena); diff --git a/mozilla/security/nss/lib/dev/devslot.c b/mozilla/security/nss/lib/dev/devslot.c index 18f11f020c7..04bbda5bba9 100644 --- a/mozilla/security/nss/lib/dev/devslot.c +++ b/mozilla/security/nss/lib/dev/devslot.c @@ -32,7 +32,7 @@ */ #ifdef DEBUG -static const char CVS_ID[] = "@(#) $RCSfile: devslot.c,v $ $Revision: 1.17 $ $Date: 2003-07-11 21:52:04 $ $Name: not supported by cvs2svn $"; +static const char CVS_ID[] = "@(#) $RCSfile: devslot.c,v $ $Revision: 1.18 $ $Date: 2003-08-01 02:02:43 $ $Name: not supported by cvs2svn $"; #endif /* DEBUG */ #ifndef NSSCKEPV_H @@ -178,8 +178,7 @@ nssSlot_Destroy ( ) { if (slot) { - PR_AtomicDecrement(&slot->base.refCount); - if (slot->base.refCount == 0) { + if (PR_AtomicDecrement(&slot->base.refCount) == 0) { PZ_DestroyLock(slot->base.lock); #ifdef PURE_STAN_BUILD nssToken_Destroy(slot->token); diff --git a/mozilla/security/nss/lib/dev/devtoken.c b/mozilla/security/nss/lib/dev/devtoken.c index f6944e2069c..73a194f8a70 100644 --- a/mozilla/security/nss/lib/dev/devtoken.c +++ b/mozilla/security/nss/lib/dev/devtoken.c @@ -32,7 +32,7 @@ */ #ifdef DEBUG -static const char CVS_ID[] = "@(#) $RCSfile: devtoken.c,v $ $Revision: 1.34 $ $Date: 2003-07-01 00:32:20 $ $Name: not supported by cvs2svn $"; +static const char CVS_ID[] = "@(#) $RCSfile: devtoken.c,v $ $Revision: 1.35 $ $Date: 2003-08-01 02:02:43 $ $Name: not supported by cvs2svn $"; #endif /* DEBUG */ #ifndef NSSCKEPV_H @@ -152,8 +152,7 @@ nssToken_Destroy ( ) { if (tok) { - PR_AtomicDecrement(&tok->base.refCount); - if (tok->base.refCount == 0) { + if (PR_AtomicDecrement(&tok->base.refCount) == 0) { PZ_DestroyLock(tok->base.lock); nssTokenObjectCache_Destroy(tok->cache); return nssArena_Destroy(tok->base.arena); diff --git a/mozilla/security/nss/lib/pki/certificate.c b/mozilla/security/nss/lib/pki/certificate.c index 541d834052a..c6928daabc0 100644 --- a/mozilla/security/nss/lib/pki/certificate.c +++ b/mozilla/security/nss/lib/pki/certificate.c @@ -32,7 +32,7 @@ */ #ifdef DEBUG -static const char CVS_ID[] = "@(#) $RCSfile: certificate.c,v $ $Revision: 1.46 $ $Date: 2003-01-30 05:12:10 $ $Name: not supported by cvs2svn $"; +static const char CVS_ID[] = "@(#) $RCSfile: certificate.c,v $ $Revision: 1.47 $ $Date: 2003-08-01 02:02:46 $ $Name: not supported by cvs2svn $"; #endif /* DEBUG */ #ifndef NSSPKI_H @@ -131,8 +131,7 @@ nssCertificate_Destroy ( } else { nssTrustDomain_LockCertCache(td); } - PR_AtomicDecrement(&c->object.refCount); - if (c->object.refCount == 0) { + if (PR_AtomicDecrement(&c->object.refCount) == 0) { /* --- remove cert and UNLOCK storage --- */ if (cc) { nssCertificateStore_RemoveCertLOCKED(cc->certStore, c); diff --git a/mozilla/security/nss/lib/pki/pkibase.c b/mozilla/security/nss/lib/pki/pkibase.c index e923b182fc3..6fbc532f159 100644 --- a/mozilla/security/nss/lib/pki/pkibase.c +++ b/mozilla/security/nss/lib/pki/pkibase.c @@ -32,7 +32,7 @@ */ #ifdef DEBUG -static const char CVS_ID[] = "@(#) $RCSfile: pkibase.c,v $ $Revision: 1.20 $ $Date: 2003-05-02 03:01:13 $ $Name: not supported by cvs2svn $"; +static const char CVS_ID[] = "@(#) $RCSfile: pkibase.c,v $ $Revision: 1.21 $ $Date: 2003-08-01 02:02:47 $ $Name: not supported by cvs2svn $"; #endif /* DEBUG */ #ifndef DEV_H @@ -106,8 +106,7 @@ nssPKIObject_Destroy ( { PRUint32 i; PR_ASSERT(object->refCount > 0); - PR_AtomicDecrement(&object->refCount); - if (object->refCount == 0) { + if (PR_AtomicDecrement(&object->refCount) == 0) { for (i=0; inumInstances; i++) { nssCryptokiObject_Destroy(object->instances[i]); }