GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: avoid X509_free in loops in crypto_x509.cc · nodejs/node@7ca77dd

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/crypto
    • crypto_context.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/crypto/crypto_context.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_context.cc
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -699,15 +699,14 @@ void SecureContext::AddCACert(const FunctionCallbackInfo<Value>& args) {
699699
return;
700700

701701
X509_STORE* cert_store = SSL_CTX_get_cert_store(sc->ctx_.get());
702-
while (X509* x509 = PEM_read_bio_X509_AUX(
703-
bio.get(), nullptr, NoPasswordCallback, nullptr)) {
702+
while (X509Pointer x509 = X509Pointer(PEM_read_bio_X509_AUX(
703+
bio.get(), nullptr, NoPasswordCallback, nullptr))) {
704704
if (cert_store == root_cert_store) {
705705
cert_store = NewRootCertStore();
706706
SSL_CTX_set_cert_store(sc->ctx_.get(), cert_store);
707707
}
708-
X509_STORE_add_cert(cert_store, x509);
709-
SSL_CTX_add_client_CA(sc->ctx_.get(), x509);
710-
X509_free(x509);
708+
X509_STORE_add_cert(cert_store, x509.get());
709+
SSL_CTX_add_client_CA(sc->ctx_.get(), x509.get());
711710
}
712711
}
713712

@@ -1311,10 +1310,9 @@ unsigned long AddCertsFromFile( // NOLINT(runtime/int)
13111310
if (!bio)
13121311
return ERR_get_error();
13131312

1314-
while (X509* x509 =
1315-
PEM_read_bio_X509(bio.get(), nullptr, NoPasswordCallback, nullptr)) {
1316-
X509_STORE_add_cert(store, x509);
1317-
X509_free(x509);
1313+
while (X509Pointer x509 = X509Pointer(PEM_read_bio_X509(
1314+
bio.get(), nullptr, NoPasswordCallback, nullptr))) {
1315+
X509_STORE_add_cert(store, x509.get());
13181316
}
13191317

13201318
unsigned long err = ERR_peek_error(); // NOLINT(runtime/int)

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.