Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYash Ladha <yashladhapankajladha123@gmail.com>2021-01-30 11:20:21 +0300
committerDanielle Adams <adamzdanielle@gmail.com>2021-02-16 17:12:46 +0300
commit354df9e8a179778d709a91e023a8f790c05aa0c5 (patch)
tree6c18a9a522299f44b9c877fee7a309706920d5c2 /src
parentacabe08b10efeee68900e9356a3d4bcced103bb1 (diff)
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: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'src')
-rw-r--r--src/env.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/env.cc b/src/env.cc
index 16c6fcc3db4..91789c3476f 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -379,9 +379,10 @@ Environment::Environment(IsolateData* isolate_data,
// easier to modify them after Environment creation. The defaults are
// part of the per-Isolate option set, for which in turn the defaults are
// part of the per-process option set.
- options_.reset(new EnvironmentOptions(*isolate_data->options()->per_env));
- inspector_host_port_.reset(
- new ExclusiveAccess<HostPort>(options_->debug_options().host_port));
+ options_ = std::make_shared<EnvironmentOptions>(
+ *isolate_data->options()->per_env);
+ inspector_host_port_ = std::make_shared<ExclusiveAccess<HostPort>>(
+ options_->debug_options().host_port);
if (!(flags_ & EnvironmentFlags::kOwnsProcessState)) {
set_abort_on_uncaught_exception(false);