From da26e1e1a2d1361c73c7aceb1bd8c6210dcc102f Mon Sep 17 00:00:00 2001 From: xdmal Date: Wed, 20 Apr 2022 17:08:04 +0800 Subject: [PATCH] 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 --- util/native_module_util.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/util/native_module_util.cpp b/util/native_module_util.cpp index 90603f8..a65a25c 100755 --- a/util/native_module_util.cpp +++ b/util/native_module_util.cpp @@ -483,7 +483,7 @@ namespace OHOS::Util { { const char *textEncoderClassName = "TextEncoder"; napi_value textEncoderClass = nullptr; - static napi_property_descriptor textEncoderDesc[] = { + napi_property_descriptor textEncoderDesc[] = { DECLARE_NAPI_GETTER("encoding", GetEncoding), DECLARE_NAPI_FUNCTION("encode", Encode), DECLARE_NAPI_FUNCTION("encodeInto", EncodeInto), @@ -495,7 +495,7 @@ namespace OHOS::Util { const char *textDecoderClassName = "TextDecoder"; napi_value textDecoderClass = nullptr; - static napi_property_descriptor textdecoderDesc[] = { + napi_property_descriptor textdecoderDesc[] = { DECLARE_NAPI_FUNCTION("decode", TextdecoderDecode), DECLARE_NAPI_GETTER("encoding", TextdecoderGetEncoding), DECLARE_NAPI_GETTER("fatal", TextdecoderGetFatal), @@ -506,7 +506,7 @@ namespace OHOS::Util { sizeof(textdecoderDesc) / sizeof(textdecoderDesc[0]), textdecoderDesc, &textDecoderClass)); - static napi_property_descriptor desc[] = { + napi_property_descriptor desc[] = { DECLARE_NAPI_PROPERTY("TextEncoder", textEncoderClass), DECLARE_NAPI_PROPERTY("TextDecoder", textDecoderClass), }; @@ -1223,7 +1223,7 @@ namespace OHOS::Util { { const char* typeofClassName = "Types"; napi_value typeofClass = nullptr; - static napi_property_descriptor typeofDesc[] = { + napi_property_descriptor typeofDesc[] = { DECLARE_NAPI_FUNCTION("isBigInt64Array", IsBigInt64Array), DECLARE_NAPI_FUNCTION("isBigUint64Array", IsBigUint64Array), DECLARE_NAPI_FUNCTION("isBooleanObject", IsBooleanObject), @@ -1267,7 +1267,7 @@ namespace OHOS::Util { NAPI_CALL(env, napi_define_class(env, typeofClassName, strlen(typeofClassName), TypesConstructor, nullptr, sizeof(typeofDesc) / sizeof(typeofDesc[0]), typeofDesc, &typeofClass)); - static napi_property_descriptor desc[] = { DECLARE_NAPI_PROPERTY("Types", typeofClass) }; + napi_property_descriptor desc[] = { DECLARE_NAPI_PROPERTY("Types", typeofClass) }; NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc)); return exports; } @@ -1276,7 +1276,7 @@ namespace OHOS::Util { { const char *base64ClassName = "Base64"; napi_value base64Class = nullptr; - static napi_property_descriptor base64Desc[] = { + napi_property_descriptor base64Desc[] = { DECLARE_NAPI_FUNCTION("encodeSync", EncodeBase64), DECLARE_NAPI_FUNCTION("encodeToStringSync", EncodeToString), DECLARE_NAPI_FUNCTION("decodeSync", DecodeBase64), @@ -1287,7 +1287,7 @@ namespace OHOS::Util { NAPI_CALL(env, napi_define_class(env, base64ClassName, strlen(base64ClassName), Base64Constructor, nullptr, sizeof(base64Desc) / sizeof(base64Desc[0]), base64Desc, &base64Class)); - static napi_property_descriptor desc[] = { + napi_property_descriptor desc[] = { DECLARE_NAPI_PROPERTY("Base64", base64Class) }; NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc)); @@ -1296,7 +1296,7 @@ namespace OHOS::Util { static napi_value UtilInit(napi_env env, napi_value exports) { - static napi_property_descriptor desc[] = { + napi_property_descriptor desc[] = { DECLARE_NAPI_FUNCTION("printf", Printf), DECLARE_NAPI_FUNCTION("geterrorstring", GetErrorString), DECLARE_NAPI_FUNCTION("dealwithformatstring", DealWithFormatString), -- Gitee