!12379 Drawing 安全编码修复

Merge pull request !12379 from yzj688/master
This commit is contained in:
openharmony_ci 2024-06-26 11:31:39 +00:00 committed by Gitee
commit c02e94a228
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 7 additions and 3 deletions

View File

@ -119,7 +119,7 @@ napi_value JsColorFilter::CreateBlendModeColorFilter(napi_env env, napi_callback
}
int32_t jsMode = 0;
GET_INT32_CHECK_GE_ZERO_PARAM(ARGC_ONE, jsMode);
GET_ENUM_PARAM(ARGC_ONE, jsMode, 0, static_cast<int32_t>(BlendMode::LUMINOSITY));
auto color = Color::ColorQuadSetARGB(argb[ARGC_ZERO], argb[ARGC_ONE], argb[ARGC_TWO], argb[ARGC_THREE]);
std::shared_ptr<ColorFilter> colorFilter = ColorFilter::CreateBlendModeColorFilter(color, BlendMode(jsMode));

View File

@ -84,6 +84,10 @@ napi_value JsFont::Constructor(napi_env env, napi_callback_info info)
std::shared_ptr<Font> font = std::make_shared<Font>();
font->SetTypeface(JsTypeface::LoadZhCnTypeface());
JsFont *jsFont = new(std::nothrow) JsFont(font);
if (!jsFont) {
ROSEN_LOGE("Failed to create JsFont");
return nullptr;
}
status = napi_wrap(env, jsThis, jsFont,
JsFont::Destructor, nullptr, nullptr);

View File

@ -103,7 +103,7 @@ napi_value JsMaskFilter::CreateBlurMaskFilter(napi_env env, napi_callback_info i
CHECK_PARAM_NUMBER_WITHOUT_OPTIONAL_PARAMS(argv, ARGC_TWO);
int32_t blurType = 0;
GET_INT32_CHECK_GE_ZERO_PARAM(ARGC_ZERO, blurType);
GET_ENUM_PARAM(ARGC_ZERO, blurType, 0, static_cast<int32_t>(BlurType::INNER));
double sigma = 0.0;
GET_DOUBLE_PARAM(ARGC_ONE, sigma);

View File

@ -105,10 +105,10 @@ napi_value JsPathEffect::CreateDashPathEffect(napi_env env, napi_callback_info i
uint32_t arrayLength = 0;
if ((napi_get_array_length(env, argv[ARGC_ZERO], &arrayLength) != napi_ok)) {
ROSEN_LOGE("JsPathEffect::CreateDashPathEffect count of intervals is not even : %{public}u", arrayLength);
return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Invalid array length params.");
}
if (arrayLength % NUMBER_TWO || arrayLength < NUMBER_TWO) { // arrayLength must be an even number greater than 0
ROSEN_LOGE("JsPathEffect::CreateDashPathEffect count of intervals is not even : %{public}u", arrayLength);
return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM,
"parameter array length verification failed.");
}