Skip to content

Commit 3265f3b

Browse files
authored
Address minor issues reported by coverity scan
1 parent 95ba31b commit 3265f3b

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/nss/app.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,9 @@ xmlSecNssAppPkcs12LoadSECItem(SECItem* secItem, const char *pwd,
862862
SECKEYPrivateKey *privkey = NULL;
863863
SECKEYPublicKey *pubkey = NULL;
864864
CERTCertList *certlist = NULL;
865-
CERTCertListNode *head = NULL;
866-
CERTCertificate *cert = NULL;
867-
CERTCertificate *tmpcert = NULL;
865+
CERTCertListNode *head = NULL;
866+
CERTCertificate *cert = NULL;
867+
CERTCertificate *tmpcert = NULL;
868868
SEC_PKCS12DecoderContext *p12ctx = NULL;
869869
const SEC_PKCS12DecoderItem *dip;
870870
size_t pwdSize;
@@ -982,7 +982,6 @@ xmlSecNssAppPkcs12LoadSECItem(SECItem* secItem, const char *pwd,
982982
ret = xmlSecNssKeyDataX509AdoptKeyCert(x509Data, tmpcert);
983983
if(ret < 0) {
984984
xmlSecInternalError("xmlSecNssKeyDataX509AdoptKeyCert", NULL);
985-
CERT_DestroyCertificate(tmpcert);
986985
goto done;
987986
}
988987
tmpcert = NULL; /* owned by x509Data now */
@@ -995,7 +994,6 @@ xmlSecNssAppPkcs12LoadSECItem(SECItem* secItem, const char *pwd,
995994
ret = xmlSecNssKeyDataX509AdoptCert(x509Data, tmpcert);
996995
if(ret < 0) {
997996
xmlSecInternalError("xmlSecNssKeyDataX509AdoptCert", NULL);
998-
CERT_DestroyCertificate(tmpcert);
999997
goto done;
1000998
}
1001999
tmpcert = NULL; /* owned by x509Data now */
@@ -1053,6 +1051,9 @@ xmlSecNssAppPkcs12LoadSECItem(SECItem* secItem, const char *pwd,
10531051
key = NULL;
10541052

10551053
done:
1054+
if(tmpcert != NULL) {
1055+
CERT_DestroyCertificate(tmpcert);
1056+
}
10561057
if(key != NULL) {
10571058
xmlSecKeyDestroy(key);
10581059
}

src/nss/x509.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ xmlSecNssKeyDataX509Duplicate(xmlSecKeyDataPtr dst, xmlSecKeyDataPtr src) {
581581
return(-1);
582582
}
583583
}
584-
cert = NULL; /* owned by dst now */
584+
/* cert is owned by dst now */
585585
}
586586
}
587587

@@ -1463,7 +1463,7 @@ xmlSecNssX509CrlListDuplicate(xmlSecNssX509CrlNodePtr head) {
14631463
xmlSecNssX509CrlListDestroy(newHead);
14641464
return(NULL);
14651465
}
1466-
crl = NULL; /* owned by newHead now */
1466+
/* crl is owned by newHead now */
14671467
}
14681468

14691469
/* done */

src/openssl/app.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,6 @@ xmlSecOpenSSLAppStoreKeyLoad(const char *uri, xmlSecKeyDataType type, const char
892892
ret = sk_X509_push(certs, cert);
893893
if(ret <= 0) {
894894
xmlSecOpenSSLError("sk_X509_push", NULL);
895-
X509_free(cert);
896895
goto done;
897896
}
898897
cert = NULL; /* owned by certs now */
@@ -942,6 +941,9 @@ xmlSecOpenSSLAppStoreKeyLoad(const char *uri, xmlSecKeyDataType type, const char
942941
/* success! */
943942

944943
done:
944+
if(cert != NULL) {
945+
X509_free(cert);
946+
}
945947
if(pPrivKey != NULL) {
946948
EVP_PKEY_free(pPrivKey);
947949
}

0 commit comments

Comments
 (0)