Skip to content

Commit

Permalink
Use proper ref count handling when adding to x509 store
Browse files Browse the repository at this point in the history
  • Loading branch information
ColtonWilley committed Nov 27, 2024
1 parent e9a4f7d commit c5df3cb
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/x509_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -1408,24 +1408,30 @@ int wolfSSL_X509_STORE_add_cert(WOLFSSL_X509_STORE* store, WOLFSSL_X509* x509)
result = X509StoreAddCa(store, x509, WOLFSSL_USER_CA);
#if !defined(WOLFSSL_SIGNER_DER_CERT)
if (result == WOLFSSL_SUCCESS && store->trusted != NULL) {
result = wolfSSL_sk_X509_push(store->trusted, x509);
if (result > 0) {
result = WOLFSSL_SUCCESS;
}
else {
result = WOLFSSL_FATAL_ERROR;
result = wolfSSL_X509_up_ref(x509);
if (result == WOLFSSL_SUCCESS) {
result = wolfSSL_sk_X509_push(store->trusted, x509);
if (result > 0) {
result = WOLFSSL_SUCCESS;
}
else {
result = WOLFSSL_FATAL_ERROR;
}
}
}
#endif
}
else {
if (store->certs != NULL) {
result = wolfSSL_sk_X509_push(store->certs, x509);
if (result > 0) {
result = WOLFSSL_SUCCESS;
}
else {
result = WOLFSSL_FATAL_ERROR;
result = wolfSSL_X509_up_ref(x509);
if (result == WOLFSSL_SUCCESS) {
result = wolfSSL_sk_X509_push(store->certs, x509);
if (result > 0) {
result = WOLFSSL_SUCCESS;
}
else {
result = WOLFSSL_FATAL_ERROR;
}
}
}
else {
Expand Down

0 comments on commit c5df3cb

Please sign in to comment.