Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bbfd2e3

Browse filesBrowse files
AdamMajerMylesBorins
authored andcommitted
crypto: do not use pointers to std::vector
The pointer to std::vector is unnecessary, so replace it with standard instance. Also, make the for() loop more readable by using actual type instead of inferred - there is no readability benefit here from obfuscating the type. PR-URL: #8334 Backport-PR-URL: #11794 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
1 parent 2b3381a commit bbfd2e3
Copy full SHA for bbfd2e3

File tree

Expand file treeCollapse file tree

1 file changed

+4
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-6
lines changed
Open diff view settings
Collapse file

‎src/node_crypto.cc‎

Copy file name to clipboardExpand all lines: src/node_crypto.cc
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const char* const root_certs[] = {
127127
std::string extra_root_certs_file; // NOLINT(runtime/string)
128128

129129
X509_STORE* root_cert_store;
130-
std::vector<X509*>* root_certs_vector;
130+
std::vector<X509*> root_certs_vector;
131131

132132
// Just to generate static methods
133133
template class SSLWrap<TLSWrap>;
@@ -694,9 +694,7 @@ static int X509_up_ref(X509* cert) {
694694

695695

696696
static X509_STORE* NewRootCertStore() {
697-
if (!root_certs_vector) {
698-
root_certs_vector = new std::vector<X509*>;
699-
697+
if (root_certs_vector.empty()) {
700698
for (size_t i = 0; i < arraysize(root_certs); i++) {
701699
BIO* bp = NodeBIO::NewFixed(root_certs[i], strlen(root_certs[i]));
702700
X509 *x509 = PEM_read_bio_X509(bp, nullptr, CryptoPemCallback, nullptr);
@@ -705,12 +703,12 @@ static X509_STORE* NewRootCertStore() {
705703
// Parse errors from the built-in roots are fatal.
706704
CHECK_NE(x509, nullptr);
707705

708-
root_certs_vector->push_back(x509);
706+
root_certs_vector.push_back(x509);
709707
}
710708
}
711709

712710
X509_STORE* store = X509_STORE_new();
713-
for (auto& cert : *root_certs_vector) {
711+
for (X509 *cert : root_certs_vector) {
714712
X509_up_ref(cert);
715713
X509_STORE_add_cert(store, cert);
716714
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.