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 354df9e

Browse filesBrowse files
yashLadhadanielleadams
authored andcommitted
src: use make_shared for safe allocation
Using the reset does a double allocation and is error prone if some exception occured which is very unlikely but can happen. make_shared_ptr gives hedge over this and handle the failure in allocation. PR-URL: #37139 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent acabe08 commit 354df9e
Copy full SHA for 354df9e

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

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

‎src/env.cc‎

Copy file name to clipboardExpand all lines: src/env.cc
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,10 @@ Environment::Environment(IsolateData* isolate_data,
379379
// easier to modify them after Environment creation. The defaults are
380380
// part of the per-Isolate option set, for which in turn the defaults are
381381
// part of the per-process option set.
382-
options_.reset(new EnvironmentOptions(*isolate_data->options()->per_env));
383-
inspector_host_port_.reset(
384-
new ExclusiveAccess<HostPort>(options_->debug_options().host_port));
382+
options_ = std::make_shared<EnvironmentOptions>(
383+
*isolate_data->options()->per_env);
384+
inspector_host_port_ = std::make_shared<ExclusiveAccess<HostPort>>(
385+
options_->debug_options().host_port);
385386

386387
if (!(flags_ & EnvironmentFlags::kOwnsProcessState)) {
387388
set_abort_on_uncaught_exception(false);

0 commit comments

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