Bug 1050069 - 389-ds-base server reports crash in stan_GetCERTCertificate under the replication replay failure condition, a=wtc, r=rrelyea,emaldona
authorElio Maldonado <emaldona@redhat.com>
Sat, 28 Feb 2015 14:41:56 -0800
changeset 11383 c765bf1d4e4baa77c69e3c1406425629c61948e7
parent 11382 4420be59d614b6f547a2bce0de19fde54713e208
child 11384 e07a62e9dd8883f2eb5d191105622e4daa572242
push id585
push useremaldona@redhat.com
push dateSat, 28 Feb 2015 23:10:37 +0000
reviewerswtc, rrelyea, emaldona
bugs1050069
Bug 1050069 - 389-ds-base server reports crash in stan_GetCERTCertificate under the replication replay failure condition, a=wtc, r=rrelyea,emaldona
lib/pki/tdcache.c
--- a/lib/pki/tdcache.c
+++ b/lib/pki/tdcache.c
@@ -432,27 +432,31 @@ nssTrustDomain_RemoveTokenCertsFromCache
 	return PR_FAILURE;
     }
     dtor.cache = td->cache;
     dtor.token = token;
     dtor.certs = certs;
     dtor.numCerts = 0;
     dtor.arrSize = arrSize;
     PZ_Lock(td->cache->lock);
-    nssHash_Iterate(td->cache->issuerAndSN, remove_token_certs, (void *)&dtor);
+    nssHash_Iterate(td->cache->issuerAndSN, remove_token_certs, &dtor);
     for (i=0; i<dtor.numCerts; i++) {
 	if (dtor.certs[i]->object.numInstances == 0) {
 	    nssTrustDomain_RemoveCertFromCacheLOCKED(td, dtor.certs[i]);
 	    dtor.certs[i] = NULL;  /* skip this cert in the second for loop */
+	} else {
+	    /* make sure it doesn't disappear on us before we finish */
+	    nssCertificate_AddRef(dtor.certs[i]);
 	}
     }
     PZ_Unlock(td->cache->lock);
     for (i=0; i<dtor.numCerts; i++) {
 	if (dtor.certs[i]) {
 	    STAN_ForceCERTCertificateUpdate(dtor.certs[i]);
+	    nssCertificate_Destroy(dtor.certs[i]);
 	}
     }
     nss_ZFreeIf(dtor.certs);
     return PR_SUCCESS;
 }
 
 NSS_IMPLEMENT PRStatus
 nssTrustDomain_UpdateCachedTokenCerts (