Resolve multithreaded use case crashes

Fix the static napi_property_descriptor to napi_property_descriptor

issue: https://gitee.com/openharmony/js_util_module/issues/I53PXU

Signed-off-by: xdmal <maxiaodong16@huawei.com>
This commit is contained in:
xdmal
2022-04-20 17:11:18 +08:00
parent a65d03e135
commit 43f3e6b102
5 changed files with 18 additions and 16 deletions
+4 -4
View File
@@ -349,7 +349,7 @@ namespace OHOS::xml {
{
const char *xmlSerializerClass = "XmlSerializer";
napi_value xmlClass = nullptr;
static napi_property_descriptor xmlDesc[] = {
napi_property_descriptor xmlDesc[] = {
DECLARE_NAPI_FUNCTION("setAttributes", SetAttributes),
DECLARE_NAPI_FUNCTION("addEmptyElement", AddEmptyElement),
DECLARE_NAPI_FUNCTION("setDeclaration", SetDeclaration),
@@ -364,7 +364,7 @@ namespace OHOS::xml {
};
NAPI_CALL(env, napi_define_class(env, xmlSerializerClass, strlen(xmlSerializerClass), XmlSerializerConstructor,
nullptr, sizeof(xmlDesc) / sizeof(xmlDesc[0]), xmlDesc, &xmlClass));
static napi_property_descriptor desc[] = {
napi_property_descriptor desc[] = {
DECLARE_NAPI_PROPERTY("XmlSerializer", xmlClass)
};
napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
@@ -409,14 +409,14 @@ namespace OHOS::xml {
{
const char *xmlPullParserClass = "XmlPullParser";
napi_value xmlClass = nullptr;
static napi_property_descriptor xmlDesc[] = {
napi_property_descriptor xmlDesc[] = {
DECLARE_NAPI_FUNCTION("parse", Parse),
DECLARE_NAPI_FUNCTION("XmlPullParserError", XmlPullParserError)
};
NAPI_CALL(env, napi_define_class(env, xmlPullParserClass, strlen(xmlPullParserClass),
XmlPullParserConstructor, nullptr, sizeof(xmlDesc) / sizeof(xmlDesc[0]),
xmlDesc, &xmlClass));
static napi_property_descriptor desc[] = {
napi_property_descriptor desc[] = {
DECLARE_NAPI_PROPERTY("XmlPullParser", xmlClass)
};
napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);