Browse Source

src: fix v8 local handling in node_url.cc

Calling `.As<Object>()` on a non-object aborts in debug mode,
but `node_url.cc` relied on it. Address that by using `Local<Value>`
until it has been confirmed that the handle actually is an object.

PR-URL: https://github.com/nodejs/node/pull/11064
Reviewed-By: Michal Zasso <targos@protonmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6
Anna Henningsen 8 years ago
committed by James M Snell
parent
commit
0d290a2ae0
  1. 12
      src/node_url.cc

12
src/node_url.cc

@ -636,8 +636,8 @@ namespace url {
const char* input,
const size_t len,
enum url_parse_state override,
Local<Object> base_obj,
Local<Object> context_obj,
Local<Value> base_obj,
Local<Value> context_obj,
Local<Function> cb) {
Isolate* isolate = env->isolate();
Local<Context> context = env->context();
@ -654,9 +654,9 @@ namespace url {
struct url_data base;
struct url_data url;
if (context_obj->IsObject())
HarvestContext(env, &url, context_obj);
HarvestContext(env, &url, context_obj.As<Object>());
if (has_base)
HarvestBase(env, &base, base_obj);
HarvestBase(env, &base, base_obj.As<Object>());
std::string buffer;
url.scheme.reserve(len);
@ -1321,8 +1321,8 @@ namespace url {
Parse(env, args.This(),
*input, input.length(),
override,
args[2].As<Object>(),
args[3].As<Object>(),
args[2],
args[3],
args[4].As<Function>());
}

Loading…
Cancel
Save