summaryrefslogtreecommitdiff
path: root/src/js_native_api_v8.cc
diff options
context:
space:
mode:
authorOctavian Soldea <octavian.soldea@intel.com>2019-05-28 21:12:24 -0700
committerGabriel Schulhof <gabriel.schulhof@intel.com>2019-06-07 21:33:00 -0700
commita18e27df9ec29b1633146116810eeb14a3dd335f (patch)
tree539d904ee3a8495d1fd05674956f1496e47b0658 /src/js_native_api_v8.cc
parent9611d75943eba359f7d083688591ac210960e466 (diff)
downloadandroid-node-v8-a18e27df9ec29b1633146116810eeb14a3dd335f.tar.gz
android-node-v8-a18e27df9ec29b1633146116810eeb14a3dd335f.tar.bz2
android-node-v8-a18e27df9ec29b1633146116810eeb14a3dd335f.zip
src: add napi_define_class() null checks
napi_define_class is tested by passing NULL to all parameters that are pointers, one at a time. Moreover, two bugs were corrected. One was utf8name and the second was the property descriptor pointer. These pointers were assumed to be non-NULL and now we have NULL checks. PR-URL: https://github.com/nodejs/node/pull/27945 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Diffstat (limited to 'src/js_native_api_v8.cc')
-rw-r--r--src/js_native_api_v8.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc
index 413231dd36..1131e3a6d1 100644
--- a/src/js_native_api_v8.cc
+++ b/src/js_native_api_v8.cc
@@ -24,6 +24,9 @@
RETURN_STATUS_IF_FALSE((env), \
(len == NAPI_AUTO_LENGTH) || len <= INT_MAX, \
napi_invalid_arg); \
+ RETURN_STATUS_IF_FALSE((env), \
+ (str) != nullptr, \
+ napi_invalid_arg); \
auto str_maybe = v8::String::NewFromUtf8( \
(env)->isolate, (str), v8::NewStringType::kInternalized, \
static_cast<int>(len)); \
@@ -768,6 +771,10 @@ napi_status napi_define_class(napi_env env,
CHECK_ARG(env, result);
CHECK_ARG(env, constructor);
+ if (property_count > 0) {
+ CHECK_ARG(env, properties);
+ }
+
v8::Isolate* isolate = env->isolate;
v8::EscapableHandleScope scope(isolate);