Skip to content

Commit c7b7f33

Browse files
authored
Merge pull request #256 from OpenZWave/bugfix/issue#214-crash-on-empty-options
check for existence of an options object
2 parents 1d8c362 + 41ebb0d commit c7b7f33

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/openzwave.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,11 @@ namespace OZW {
212212
::std::string option_overrides;
213213
bool log_initialisation = true;
214214
// Options are global for all drivers and can only be set once.
215-
if (info.Length() > 0) {
215+
if (info.Length() > 0 && !info[0]->IsUndefined()) {
216216
Local < Object > opts = Nan::To<Object>(info[0]).ToLocalChecked();
217-
Local < Array > props = Nan::GetOwnPropertyNames(opts).ToLocalChecked();
217+
MaybeLocal <v8::Array> propsmaybe = Nan::GetOwnPropertyNames(opts);
218+
if (propsmaybe.IsUndefined()) return;
219+
Local < Array > props = propsmaybe.ToLocalChecked();
218220
for (unsigned int i = 0; i < props->Length(); ++i) {
219221
Local<Value> key = props->Get(i);
220222
::std::string keyname = *Nan::Utf8String(key);

0 commit comments

Comments
 (0)