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 781ad96

Browse filesBrowse files
tniessendanielleadams
authored andcommitted
src: use OnScopeLeave instead of multiple free()
This is not great either but it avoids having to call OPENSSL_free() in more than one branch, thus reducing the risk of memory leaks. PR-URL: #44852 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c7ece46 commit 781ad96
Copy full SHA for 781ad96

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

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

‎src/crypto/crypto_common.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_common.cc
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -992,18 +992,17 @@ static MaybeLocal<Value> GetX509NameObject(Environment* env, X509* cert) {
992992
if (value_str_size < 0) {
993993
return Undefined(env->isolate());
994994
}
995+
auto free_value_str = OnScopeLeave([&]() { OPENSSL_free(value_str); });
995996

996997
Local<String> v8_value;
997998
if (!String::NewFromUtf8(env->isolate(),
998999
reinterpret_cast<const char*>(value_str),
9991000
NewStringType::kNormal,
1000-
value_str_size).ToLocal(&v8_value)) {
1001-
OPENSSL_free(value_str);
1001+
value_str_size)
1002+
.ToLocal(&v8_value)) {
10021003
return MaybeLocal<Value>();
10031004
}
10041005

1005-
OPENSSL_free(value_str);
1006-
10071006
// For backward compatibility, we only create arrays if multiple values
10081007
// exist for the same key. That is not great but there is not much we can
10091008
// change here without breaking things. Note that this creates nested data

0 commit comments

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