From b6ad568c09e92c542be1f13686e6885ef61c3fdf Mon Sep 17 00:00:00 2001 From: Ian Haken Date: Wed, 20 Jun 2018 15:01:57 -0700 Subject: [PATCH] Add type assertion on createSsl's fourth argument. --- packages/grpc-native-core/ext/channel_credentials.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/grpc-native-core/ext/channel_credentials.cc b/packages/grpc-native-core/ext/channel_credentials.cc index d56780cf..64e3df46 100644 --- a/packages/grpc-native-core/ext/channel_credentials.cc +++ b/packages/grpc-native-core/ext/channel_credentials.cc @@ -189,7 +189,11 @@ NAN_METHOD(ChannelCredentials::CreateSsl) { } verify_peer_options verify_options = {NULL, NULL, NULL}; - if (info.Length() >= 4 && info[3]->IsObject()) { + if (!info[3]->IsUndefined()) { + if (!info[3]->IsObject()) { + return Nan::ThrowTypeError("createSsl's fourth argument must be an " + "object"); + } Local context = Nan::New(); Local object = info[3]->ToObject(); MaybeLocal maybe_props = object->GetOwnPropertyNames(context);