diff --git a/src/node_env_var.cc b/src/node_env_var.cc index 5f543a5e76a1f9..9df5ca822023fb 100644 --- a/src/node_env_var.cc +++ b/src/node_env_var.cc @@ -227,7 +227,7 @@ void MapKVStore::Set(Isolate* isolate, Local key, Local value) { Mutex::ScopedLock lock(mutex_); Utf8Value key_str(isolate, key); Utf8Value value_str(isolate, value); - if (*key_str != nullptr && *value_str != nullptr) { + if (*key_str != nullptr && key_str.length() > 0 && *value_str != nullptr) { map_[std::string(*key_str, key_str.length())] = std::string(*value_str, value_str.length()); }