1212#define GSS_C_REPLAY_FLAG 4
1313#define GSS_C_SEQUENCE_FLAG 8
1414
15- const wchar_t * to_wstring (const v8::String::Utf8Value& str) {
16- const char *bytes = *str;
15+ const wchar_t * to_wstring (const char *bytes) {
1716 unsigned int sizeOfStr = MultiByteToWideChar (CP_UTF8, 0 , bytes, -1 , NULL , 0 );
1817 wchar_t *output = new wchar_t [sizeOfStr];
1918 MultiByteToWideChar (CP_UTF8, 0 , bytes, -1 , output, sizeOfStr);
@@ -23,9 +22,16 @@ const wchar_t* to_wstring(const v8::String::Utf8Value& str) {
2322NAN_INLINE std::wstring WStringOptionValue (v8::Local<v8::Object> options, const char * _key) {
2423 Nan::HandleScope scope;
2524 v8::Local<v8::String> key = Nan::New (_key).ToLocalChecked ();
26- return !options.IsEmpty () && options->Has (key) && options->Get (key)->IsString ()
27- ? std::wstring (to_wstring (v8::String::Utf8Value (options->Get (key)->ToString ())))
28- : std::wstring ();
25+ if (options.IsEmpty () || !Nan::Has (options, key).FromMaybe (false )) {
26+ return std::wstring ();
27+ }
28+
29+ v8::Local<v8::Value> value = Nan::Get (options, key).ToLocalChecked ();
30+ if (!value->IsString ()) {
31+ return std::wstring ();
32+ }
33+
34+ return std::wstring (to_wstring (*(Nan::Utf8String (value))));
2935}
3036
3137// / KerberosClient
@@ -131,7 +137,7 @@ NAN_METHOD(KerberosServer::Step) {
131137
132138// / Global Methods
133139NAN_METHOD (InitializeClient) {
134- std::wstring service (to_wstring (v8::String::Utf8Value (info[0 ]-> ToString ( ))));
140+ std::wstring service (to_wstring (*( Nan::Utf8String (info[0 ]))));
135141 v8::Local<v8::Object> options = Nan::To<v8::Object>(info[1 ]).ToLocalChecked ();
136142 Nan::Callback* callback = new Nan::Callback (Nan::To<v8::Function>(info[2 ]).ToLocalChecked ());
137143
0 commit comments