os,vm: fix segfaults and CHECK failure · nodejs/node@6998e80 · GitHub
Skip to content

Commit 6998e80

Browse files
tniessenevanlucas
authored andcommitted
os,vm: fix segfaults and CHECK failure
Fixes multiple possible segmentation faults in node_contextify.cc and an assertion failure in node_os.cc Fixes: #12369 Fixes: #12370 PR-URL: #12371 Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 92e239d commit 6998e80

3 files changed

Lines changed: 157 additions & 48 deletions

File tree

src/node_contextify.cc

Lines changed: 113 additions & 47 deletions

src/node_os.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ using v8::Function;
3636
using v8::FunctionCallbackInfo;
3737
using v8::Integer;
3838
using v8::Local;
39+
using v8::MaybeLocal;
3940
using v8::Null;
4041
using v8::Number;
4142
using v8::Object;
@@ -318,7 +319,12 @@ static void GetUserInfo(const FunctionCallbackInfo<Value>& args) {
318319

319320
if (args[0]->IsObject()) {
320321
Local<Object> options = args[0].As<Object>();
321-
Local<Value> encoding_opt = options->Get(env->encoding_string());
322+
MaybeLocal<Value> maybe_encoding = options->Get(env->context(),
323+
env->encoding_string());
324+
if (maybe_encoding.IsEmpty())
325+
return;
326+
327+
Local<Value> encoding_opt = maybe_encoding.ToLocalChecked();
322328
encoding = ParseEncoding(env->isolate(), encoding_opt, UTF8);
323329
} else {
324330
encoding = UTF8;
Lines changed: 37 additions & 0 deletions

0 commit comments

Comments
 (0)