Bug 1065990, Dereferencing of a NULL pointer may occur on usage of Port_Znew or Port_ZAlloc for memory allocation, r=kaie
authorSachin Kumar Gupta <s.k.gupta@samsung.com>
Mon, 20 Oct 2014 22:36:54 +0200
changeset 11294 d63d3b5212becea34d3e58be40d00565638dc1fe
parent 11293 9f358fbaae22d8ca5db38fe3aecf720fac747f4f
child 11295 575919285e2bc440659c585c0a0ed219ce60fda6
push id505
push userkaie@kuix.de
push dateMon, 20 Oct 2014 20:37:02 +0000
reviewerskaie
bugs1065990
Bug 1065990, Dereferencing of a NULL pointer may occur on usage of Port_Znew or Port_ZAlloc for memory allocation, r=kaie
lib/crmf/respcli.c
--- a/lib/crmf/respcli.c
+++ b/lib/crmf/respcli.c
@@ -87,21 +87,23 @@ CMMF_CertRepContentGetResponseAtIndex(CM
 
     PORT_Assert(inCertRepContent != NULL &&
 		cmmf_CertRepContentIsIndexValid(inCertRepContent, inIndex));
     if (inCertRepContent == NULL ||
 	!cmmf_CertRepContentIsIndexValid(inCertRepContent, inIndex)) {
         return NULL;
     }
     certResponse = PORT_ZNew(CMMFCertResponse);
-    rv = cmmf_CopyCertResponse(NULL, certResponse, 
-			       inCertRepContent->response[inIndex]);
-    if (rv != SECSuccess) {
-        CMMF_DestroyCertResponse(certResponse);
-	certResponse = NULL;
+    if (certResponse){
+	rv = cmmf_CopyCertResponse(NULL, certResponse, 
+				   inCertRepContent->response[inIndex]);
+	if (rv != SECSuccess) {
+	    CMMF_DestroyCertResponse(certResponse);
+	    certResponse = NULL;
+	}
     }
     return certResponse;
 }
 
 CMMFPKIStatus
 CMMF_CertResponseGetPKIStatusInfoStatus(CMMFCertResponse *inCertResp)
 {
     PORT_Assert(inCertResp != NULL);