diff --git a/frameworks/bridge/declarative_frontend/jsview/js_location_button.cpp b/frameworks/bridge/declarative_frontend/jsview/js_location_button.cpp index 92112d07549deb93dacee1ddd97f5b394c1730fd..fd6e0647f84c5524ab02be1226e94db7bd3b6a77 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_location_button.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_location_button.cpp @@ -32,7 +32,7 @@ namespace OHOS::Ace::Framework { bool JSLocationButton::ParseComponentStyle(const JSCallbackInfo& info, LocationButtonLocationDescription& text, LocationButtonIconStyle& icon, int32_t& bg) { - if (!info[0]->IsObject()) { + if ((info.Length() < 1) || (!info[0]->IsObject())) { return false; } @@ -138,7 +138,7 @@ void JsLocationButtonClickFunction::Execute(GestureEvent& info) void JSLocationButton::JsOnClick(const JSCallbackInfo& info) { - if (!info[0]->IsFunction()) { + if ((info.Length() < 1) || (!info[0]->IsFunction())) { return; } auto jsOnClickFunc = AceType::MakeRefPtr(JSRef::Cast(info[0])); diff --git a/frameworks/bridge/declarative_frontend/jsview/js_paste_button.cpp b/frameworks/bridge/declarative_frontend/jsview/js_paste_button.cpp index fcf1353486f635354371e7c8a8b67e1684f3f69e..bd56d1b96881c9f6a9ea939def3f172dae240aae 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_paste_button.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_paste_button.cpp @@ -32,7 +32,7 @@ namespace OHOS::Ace::Framework { bool JSPasteButton::ParseComponentStyle(const JSCallbackInfo& info, PasteButtonPasteDescription& text, PasteButtonIconStyle& icon, int32_t& bg) { - if (!info[0]->IsObject()) { + if ((info.Length() < 1) || (!info[0]->IsObject())) { return false; } @@ -137,7 +137,7 @@ void JsPasteButtonClickFunction::Execute(GestureEvent& info) void JSPasteButton::JsOnClick(const JSCallbackInfo& info) { - if (!info[0]->IsFunction()) { + if ((info.Length() < 1) || (!info[0]->IsFunction())) { return; } auto frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode()); diff --git a/frameworks/bridge/declarative_frontend/jsview/js_save_button.cpp b/frameworks/bridge/declarative_frontend/jsview/js_save_button.cpp index 2df5397d3342ce8b46cc1f7bb19ae3faa0e92e03..30fb03928504645855f8c878d93b342acf92bf8e 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_save_button.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_save_button.cpp @@ -36,7 +36,7 @@ namespace OHOS::Ace::Framework { bool JSSaveButton::ParseComponentStyle(const JSCallbackInfo& info, SaveButtonSaveDescription& text, SaveButtonIconStyle& icon, int32_t& bg) { - if (!info[0]->IsObject()) { + if ((info.Length() < 1) || (!info[0]->IsObject())) { return false; } @@ -143,7 +143,7 @@ void JsSaveButtonClickFunction::Execute(GestureEvent& info) void JSSaveButton::JsOnClick(const JSCallbackInfo& info) { - if (!info[0]->IsFunction()) { + if ((info.Length() < 1) || (!info[0]->IsFunction())) { return; } auto jsOnClickFunc = AceType::MakeRefPtr(JSRef::Cast(info[0])); diff --git a/frameworks/bridge/declarative_frontend/jsview/js_sec_button_base.cpp b/frameworks/bridge/declarative_frontend/jsview/js_sec_button_base.cpp index aa9648826451e473f654b305568e2bed93d7d04c..a21f10733c851b2385d5e3cd0656a7d7902cc59a 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_sec_button_base.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_sec_button_base.cpp @@ -35,6 +35,9 @@ const std::vector HEIGHT_ADAPTIVE_POLICY = { TextHeigh void JSSecButtonBase::SetIconSize(const JSCallbackInfo& info) { + if (info.Length() < 1) { + return; + } auto theme = GetTheme(); CHECK_NULL_VOID(theme); @@ -68,6 +71,9 @@ void JSSecButtonBase::SetIconSize(const JSCallbackInfo& info) void JSSecButtonBase::SetIconColor(const JSCallbackInfo& info) { + if (info.Length() < 1) { + return; + } auto theme = GetTheme(); CHECK_NULL_VOID(theme); @@ -80,6 +86,9 @@ void JSSecButtonBase::SetIconColor(const JSCallbackInfo& info) void JSSecButtonBase::SetFontSize(const JSCallbackInfo& info) { + if (info.Length() < 1) { + return; + } auto theme = GetTheme(); CHECK_NULL_VOID(theme); @@ -93,7 +102,7 @@ void JSSecButtonBase::SetFontSize(const JSCallbackInfo& info) void JSSecButtonBase::SetFontStyle(const JSCallbackInfo& info) { - if (!info[0]->IsNumber()) { + if ((info.Length() < 1) || (!info[0]->IsNumber())) { SecurityComponentModelNG::SetFontStyle(Ace::FontStyle::NORMAL); return; } @@ -108,7 +117,7 @@ void JSSecButtonBase::SetFontStyle(const JSCallbackInfo& info) void JSSecButtonBase::SetFontWeight(const JSCallbackInfo& info) { - if (!(info[0]->IsString() || info[0]->IsNumber())) { + if ((info.Length() < 1) || (!(info[0]->IsString() || info[0]->IsNumber()))) { return; } std::string value = info[0]->ToString(); @@ -117,6 +126,9 @@ void JSSecButtonBase::SetFontWeight(const JSCallbackInfo& info) void JSSecButtonBase::SetFontFamily(const JSCallbackInfo& info) { + if (info.Length() < 1) { + return; + } std::vector fontFamilies; if (!ParseJsFontFamilies(info[0], fontFamilies)) { fontFamilies.emplace_back("HarmonyOS Sans"); @@ -126,6 +138,9 @@ void JSSecButtonBase::SetFontFamily(const JSCallbackInfo& info) void JSSecButtonBase::SetFontColor(const JSCallbackInfo& info) { + if (info.Length() < 1) { + return; + } auto theme = GetTheme(); CHECK_NULL_VOID(theme); @@ -138,7 +153,7 @@ void JSSecButtonBase::SetFontColor(const JSCallbackInfo& info) void JSSecButtonBase::SetLayoutDirection(const JSCallbackInfo& info) { - if (!info[0]->IsNumber()) { + if ((info.Length() < 1) || (!info[0]->IsNumber())) { SecurityComponentModelNG::SetTextIconLayoutDirection( SecurityComponentLayoutDirection::HORIZONTAL); return; @@ -156,6 +171,9 @@ void JSSecButtonBase::SetLayoutDirection(const JSCallbackInfo& info) void JSSecButtonBase::SetBackgroundColor(const JSCallbackInfo& info) { + if (info.Length() < 1) { + return; + } auto theme = GetTheme(); CHECK_NULL_VOID(theme); @@ -168,7 +186,7 @@ void JSSecButtonBase::SetBackgroundColor(const JSCallbackInfo& info) void JSSecButtonBase::SetBackgroundBorderStyle(const JSCallbackInfo& info) { - if (!info[0]->IsNumber()) { + if ((info.Length() < 1) || (!info[0]->IsNumber())) { SecurityComponentModelNG::SetBackgroundBorderStyle(BorderStyle::NONE); return; } @@ -183,6 +201,9 @@ void JSSecButtonBase::SetBackgroundBorderStyle(const JSCallbackInfo& info) void JSSecButtonBase::SetBackgroundBorderWidth(const JSCallbackInfo& info) { + if (info.Length() < 1) { + return; + } auto theme = GetTheme(); CHECK_NULL_VOID(theme); @@ -196,6 +217,9 @@ void JSSecButtonBase::SetBackgroundBorderWidth(const JSCallbackInfo& info) void JSSecButtonBase::SetBackgroundBorderColor(const JSCallbackInfo& info) { + if (info.Length() < 1) { + return; + } auto theme = GetTheme(); CHECK_NULL_VOID(theme); @@ -208,6 +232,9 @@ void JSSecButtonBase::SetBackgroundBorderColor(const JSCallbackInfo& info) void JSSecButtonBase::SetBackgroundBorderRadius(const JSCallbackInfo& info) { + if (info.Length() < 1) { + return; + } if (info[0]->IsObject()) { std::optional topLeft; std::optional topRight; @@ -250,6 +277,9 @@ void JSSecButtonBase::SetBackgroundBorderRadius(const JSCallbackInfo& info) void JSSecButtonBase::SetBackgroundPadding(const JSCallbackInfo& info) { + if (info.Length() < 1) { + return; + } if (info[0]->IsObject()) { std::optional left; std::optional right; @@ -289,6 +319,9 @@ void JSSecButtonBase::SetBackgroundPadding(const JSCallbackInfo& info) void JSSecButtonBase::SetTextIconSpace(const JSCallbackInfo& info) { + if (info.Length() < 1) { + return; + } auto theme = GetTheme(); CHECK_NULL_VOID(theme); @@ -302,6 +335,9 @@ void JSSecButtonBase::SetTextIconSpace(const JSCallbackInfo& info) void JSSecButtonBase::SetAlign(const JSCallbackInfo& info) { + if (info.Length() < 1) { + return; + } Alignment alignment; if (!info[0]->IsNumber()) { alignment = Alignment::CENTER; @@ -344,6 +380,9 @@ void JSSecButtonBase::SetMinFontScale(const JSCallbackInfo& info) void JSSecButtonBase::SetMaxLines(const JSCallbackInfo& info) { + if (info.Length() < 1) { + return; + } JSRef args = info[0]; auto value = Infinity(); if (args->ToString() != "Infinity") {