Skip to content

Commit

Permalink
Address minor issues reported by coverity scan
Browse files Browse the repository at this point in the history
  • Loading branch information
lsh123 committed Dec 24, 2023
1 parent 95ba31b commit 3265f3b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/nss/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,9 @@ xmlSecNssAppPkcs12LoadSECItem(SECItem* secItem, const char *pwd,
SECKEYPrivateKey *privkey = NULL;
SECKEYPublicKey *pubkey = NULL;
CERTCertList *certlist = NULL;
CERTCertListNode *head = NULL;
CERTCertificate *cert = NULL;
CERTCertificate *tmpcert = NULL;
CERTCertListNode *head = NULL;
CERTCertificate *cert = NULL;
CERTCertificate *tmpcert = NULL;
SEC_PKCS12DecoderContext *p12ctx = NULL;
const SEC_PKCS12DecoderItem *dip;
size_t pwdSize;
Expand Down Expand Up @@ -982,7 +982,6 @@ xmlSecNssAppPkcs12LoadSECItem(SECItem* secItem, const char *pwd,
ret = xmlSecNssKeyDataX509AdoptKeyCert(x509Data, tmpcert);
if(ret < 0) {
xmlSecInternalError("xmlSecNssKeyDataX509AdoptKeyCert", NULL);
CERT_DestroyCertificate(tmpcert);
goto done;
}
tmpcert = NULL; /* owned by x509Data now */
Expand All @@ -995,7 +994,6 @@ xmlSecNssAppPkcs12LoadSECItem(SECItem* secItem, const char *pwd,
ret = xmlSecNssKeyDataX509AdoptCert(x509Data, tmpcert);
if(ret < 0) {
xmlSecInternalError("xmlSecNssKeyDataX509AdoptCert", NULL);
CERT_DestroyCertificate(tmpcert);
goto done;
}
tmpcert = NULL; /* owned by x509Data now */
Expand Down Expand Up @@ -1053,6 +1051,9 @@ xmlSecNssAppPkcs12LoadSECItem(SECItem* secItem, const char *pwd,
key = NULL;

done:
if(tmpcert != NULL) {
CERT_DestroyCertificate(tmpcert);
}
if(key != NULL) {
xmlSecKeyDestroy(key);
}
Expand Down
4 changes: 2 additions & 2 deletions src/nss/x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ xmlSecNssKeyDataX509Duplicate(xmlSecKeyDataPtr dst, xmlSecKeyDataPtr src) {
return(-1);
}
}
cert = NULL; /* owned by dst now */
/* cert is owned by dst now */
}
}

Expand Down Expand Up @@ -1463,7 +1463,7 @@ xmlSecNssX509CrlListDuplicate(xmlSecNssX509CrlNodePtr head) {
xmlSecNssX509CrlListDestroy(newHead);
return(NULL);
}
crl = NULL; /* owned by newHead now */
/* crl is owned by newHead now */
}

/* done */
Expand Down
4 changes: 3 additions & 1 deletion src/openssl/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,6 @@ xmlSecOpenSSLAppStoreKeyLoad(const char *uri, xmlSecKeyDataType type, const char
ret = sk_X509_push(certs, cert);
if(ret <= 0) {
xmlSecOpenSSLError("sk_X509_push", NULL);
X509_free(cert);
goto done;
}
cert = NULL; /* owned by certs now */
Expand Down Expand Up @@ -942,6 +941,9 @@ xmlSecOpenSSLAppStoreKeyLoad(const char *uri, xmlSecKeyDataType type, const char
/* success! */

done:
if(cert != NULL) {
X509_free(cert);
}
if(pPrivKey != NULL) {
EVP_PKEY_free(pPrivKey);
}
Expand Down

0 comments on commit 3265f3b

Please sign in to comment.