Skip to content

Commit d713f56

Browse files
author
jhazik
committed
Fix references count
1 parent 483ba60 commit d713f56

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

httplib.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8984,7 +8984,9 @@ inline bool ClientImpl::create_redirect_client(
89848984
}
89858985

89868986
// Handle CA certificate store and paths if available
8987-
if (ca_cert_store_) { redirect_client.set_ca_cert_store(ca_cert_store_); }
8987+
if (ca_cert_store_ && X509_STORE_up_ref(ca_cert_store_)) {
8988+
redirect_client.set_ca_cert_store(ca_cert_store_);
8989+
}
89888990
if (!ca_cert_file_path_.empty()) {
89898991
redirect_client.set_ca_cert_path(ca_cert_file_path_, ca_cert_dir_path_);
89908992
}
@@ -10856,7 +10858,6 @@ inline SSLClient::SSLClient(const std::string &host, int port,
1085610858
}
1085710859

1085810860
inline SSLClient::~SSLClient() {
10859-
if (ca_cert_store_) { X509_STORE_free(ca_cert_store_); }
1086010861
if (ctx_) { SSL_CTX_free(ctx_); }
1086110862
// Make sure to shut down SSL since shutdown_ssl will resolve to the
1086210863
// base function rather than the derived function once we get to the
@@ -10871,7 +10872,7 @@ inline void SSLClient::set_ca_cert_store(X509_STORE *ca_cert_store) {
1087110872
if (ctx_) {
1087210873
if (SSL_CTX_get_cert_store(ctx_) != ca_cert_store) {
1087310874
// Free memory allocated for old cert and use new store `ca_cert_store`
10874-
SSL_CTX_set1_cert_store(ctx_, ca_cert_store);
10875+
SSL_CTX_set_cert_store(ctx_, ca_cert_store);
1087510876
ca_cert_store_ = ca_cert_store;
1087610877
}
1087710878
} else {

0 commit comments

Comments
 (0)