Skip to content

Commit 842f936

Browse files
addaleaxBethGriggs
authored andcommittedSep 21, 2021
src: use Isolate::TryGetCurrent where appropriate
In two places, we call `Isolate::GetCurrent()` even though that is technically invalid usage of the function. Now that V8 exposes `Isolate::TryGetCurrent()`, we can do this in a proper way. PR-URL: #39954 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 98f56d1 commit 842f936

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed
 

‎src/node.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ unsigned int reverted_cve = 0;
147147

148148
// util.h
149149
// Tells whether the per-process V8::Initialize() is called and
150-
// if it is safe to call v8::Isolate::GetCurrent().
150+
// if it is safe to call v8::Isolate::TryGetCurrent().
151151
bool v8_initialized = false;
152152

153153
// node_internals.h

‎src/node_errors.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ void OnFatalError(const char* location, const char* message) {
430430
FPrintF(stderr, "FATAL ERROR: %s\n", message);
431431
}
432432

433-
Isolate* isolate = Isolate::GetCurrent();
433+
Isolate* isolate = Isolate::TryGetCurrent();
434434
Environment* env = nullptr;
435435
if (isolate != nullptr) {
436436
env = Environment::GetCurrent(isolate);

‎src/util.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ BufferValue::BufferValue(Isolate* isolate, Local<Value> value) {
128128

129129
void LowMemoryNotification() {
130130
if (per_process::v8_initialized) {
131-
auto isolate = Isolate::GetCurrent();
131+
auto isolate = Isolate::TryGetCurrent();
132132
if (isolate != nullptr) {
133133
isolate->LowMemoryNotification();
134134
}

‎src/util.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ inline T MultiplyWithOverflowCheck(T a, T b);
9191

9292
namespace per_process {
9393
// Tells whether the per-process V8::Initialize() is called and
94-
// if it is safe to call v8::Isolate::GetCurrent().
94+
// if it is safe to call v8::Isolate::TryGetCurrent().
9595
extern bool v8_initialized;
9696
} // namespace per_process
9797

0 commit comments

Comments
 (0)
Please sign in to comment.