diff options
author | Roman Klauke <romaaan.git@gmail.com> | 2015-05-07 21:27:12 +0300 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2015-05-08 20:09:45 +0300 |
commit | 931a0d463443c68a10c8028f2ebdd01db20da1f9 (patch) | |
tree | 5babba4596ef3e30d1cbebd3462ebdd5682f6c5a /src | |
parent | 8bf878d6e5ac0faa3871cddd5dcc423ae4d3d45a (diff) |
src: add type check to v8.setFlagsFromString()
Calling v8.setFlagsFromString with e.g a function as a flag argument
gave no exception or warning that the function call will fail.
There is now an exception if the function gets called with the wrong
flag type (string is required) or that a flag is expected.
Other APIs already provide exceptions if the argument has not the
expected type.
PR-URL: https://github.com/iojs/io.js/pull/1652
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src')
-rw-r--r-- | src/node_v8.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/node_v8.cc b/src/node_v8.cc index f3bdda409d0..2834a21496b 100644 --- a/src/node_v8.cc +++ b/src/node_v8.cc @@ -60,6 +60,13 @@ void GetHeapStatistics(const FunctionCallbackInfo<Value>& args) { void SetFlagsFromString(const FunctionCallbackInfo<Value>& args) { + Environment* env = Environment::GetCurrent(args); + + if (args.Length() < 1) + return env->ThrowTypeError("v8 flag is required"); + if (!args[0]->IsString()) + return env->ThrowTypeError("v8 flag must be a string"); + String::Utf8Value flags(args[0]); V8::SetFlagsFromString(*flags, flags.length()); } |