From 548b4e21668f18a5b6337021d3fc39e7c60f5622 Mon Sep 17 00:00:00 2001 From: xdmal Date: Wed, 27 Jul 2022 18:02:59 +0800 Subject: [PATCH] Solve the crash problem of calling SetHwIcuDirectory Solve the crash problem of calling SetHwIcuDirectory issue:https://gitee.com/openharmony/js_util_module/issues/I5J8DK Signed-off-by: xdmal --- util/js_textdecoder.cpp | 5 +++++ util/js_textdecoder.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/util/js_textdecoder.cpp b/util/js_textdecoder.cpp index 2ef93df..d75fe3b 100755 --- a/util/js_textdecoder.cpp +++ b/util/js_textdecoder.cpp @@ -42,6 +42,11 @@ namespace OHOS::Util { } } label_ = i32Flag; + { + decodeLock_.lock(); + SetHwIcuDirectory(); + decodeLock_.unlock(); + } bool fatal = (i32Flag & static_cast(ConverterFlags::FATAL_FLG)) == static_cast(ConverterFlags::FATAL_FLG); diff --git a/util/js_textdecoder.h b/util/js_textdecoder.h index 8f1d0fc..19ba906 100755 --- a/util/js_textdecoder.h +++ b/util/js_textdecoder.h @@ -17,6 +17,7 @@ #define UTIL_JS_TEXTDECODER_H_ #include +#include #include #include #include "napi/native_api.h" @@ -163,6 +164,7 @@ namespace OHOS::Util { uint32_t label_; std::string encStr_; TransformToolPointer tranTool_; + std::mutex decodeLock_; }; } #endif // UTIL_JS_TEXTDECODER_H_