mirror of
https://gitee.com/openharmony/communication_wifi.git
synced 2025-01-28 03:23:40 +00:00
Wifi-sethostspotconfig参数为null,返回成功问题
Signed-off-by: lijianhua38 <lijianhua38@huawei.com>
This commit is contained in:
parent
71e7c1c0f9
commit
fab1f95f44
@ -129,7 +129,9 @@ static bool GetHotspotconfigFromJs(const napi_env& env, const napi_value& object
|
||||
config.SetChannel(AP_CHANNEL_5G_DEFAULT);
|
||||
}
|
||||
value = 0;
|
||||
JsObjectToString(env, object, "preSharedKey", NAPI_MAX_STR_LENT, str); // 64: max length
|
||||
if (!JsObjectToString(env, object, "preSharedKey", NAPI_MAX_STR_LENT, str)) { // 64: max length
|
||||
return false;
|
||||
}
|
||||
ClearJsLastException(env);
|
||||
config.SetPreSharedKey(str);
|
||||
JsObjectToInt(env, object, "maxConn", value);
|
||||
|
@ -68,14 +68,17 @@ napi_value JsObjectToString(const napi_env& env, const napi_value& object,
|
||||
|
||||
napi_get_named_property(env, object, fieldStr, &field);
|
||||
NAPI_CALL(env, napi_typeof(env, field, &valueType));
|
||||
NAPI_ASSERT(env, valueType == napi_string, "Wrong argument type. String expected.");
|
||||
if (valueType != napi_string) {
|
||||
WIFI_LOGE("Wrong argument type. String expected.");
|
||||
return NULL;
|
||||
}
|
||||
if (bufLen <= 0) {
|
||||
goto error;
|
||||
return NULL;
|
||||
}
|
||||
char *buf = (char *)malloc(bufLen);
|
||||
if (buf == nullptr) {
|
||||
WIFI_LOGE("Js object to str malloc failed");
|
||||
goto error;
|
||||
return NULL;
|
||||
}
|
||||
(void)memset_s(buf, bufLen, 0, bufLen);
|
||||
size_t result = 0;
|
||||
@ -90,9 +93,8 @@ napi_value JsObjectToString(const napi_env& env, const napi_value& object,
|
||||
buf = nullptr;
|
||||
} else {
|
||||
WIFI_LOGW("Js obj to str no property: %{public}s", fieldStr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
error:
|
||||
return UndefinedNapiValue(env);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user