diff --git a/interfaces/kits/napi/graphic/drawing/brush_napi/js_brush.cpp b/interfaces/kits/napi/graphic/drawing/brush_napi/js_brush.cpp index 1c95a65224..2e9e014bed 100644 --- a/interfaces/kits/napi/graphic/drawing/brush_napi/js_brush.cpp +++ b/interfaces/kits/napi/graphic/drawing/brush_napi/js_brush.cpp @@ -71,6 +71,11 @@ napi_value JsBrush::Constructor(napi_env env, napi_callback_info info) } JsBrush* jsBrush = new(std::nothrow) JsBrush(); + if (!jsBrush) { + ROSEN_LOGE("JsBrush::Constructor Failed to create JsBrush"); + return nullptr; + } + status = napi_wrap(env, jsThis, jsBrush, JsBrush::Destructor, nullptr, nullptr); if (status != napi_ok) { diff --git a/interfaces/kits/napi/graphic/drawing/canvas_napi/js_canvas.cpp b/interfaces/kits/napi/graphic/drawing/canvas_napi/js_canvas.cpp index 1bd766c140..16791f4178 100644 --- a/interfaces/kits/napi/graphic/drawing/canvas_napi/js_canvas.cpp +++ b/interfaces/kits/napi/graphic/drawing/canvas_napi/js_canvas.cpp @@ -276,6 +276,10 @@ napi_value JsCanvas::Constructor(napi_env env, napi_callback_info info) return nullptr; } JsCanvas *jsCanvas = new(std::nothrow) JsCanvas(g_drawingCanvas); + if (!jsCanvas) { + ROSEN_LOGE("Drawing_napi: Failed to create JsCanvas"); + return nullptr; + } status = napi_wrap(env, jsThis, jsCanvas, JsCanvas::Destructor, nullptr, nullptr); if (status != napi_ok) { delete jsCanvas; @@ -299,6 +303,10 @@ napi_value JsCanvas::Constructor(napi_env env, napi_callback_info info) Canvas* canvas = new Canvas(); canvas->Bind(bitmap); JsCanvas *jsCanvas = new(std::nothrow) JsCanvas(canvas, true); + if (!jsCanvas) { + ROSEN_LOGE("Drawing_napi: Failed to create JsCanvas"); + return nullptr; + } status = napi_wrap(env, jsThis, jsCanvas, JsCanvas::Destructor, nullptr, nullptr); if (status != napi_ok) { delete jsCanvas; diff --git a/interfaces/kits/napi/graphic/drawing/color_filter_napi/js_color_filter.cpp b/interfaces/kits/napi/graphic/drawing/color_filter_napi/js_color_filter.cpp index 64ab4776ca..2f5fb5b4d2 100644 --- a/interfaces/kits/napi/graphic/drawing/color_filter_napi/js_color_filter.cpp +++ b/interfaces/kits/napi/graphic/drawing/color_filter_napi/js_color_filter.cpp @@ -83,6 +83,11 @@ napi_value JsColorFilter::Constructor(napi_env env, napi_callback_info info) } JsColorFilter *jsColorFilter = new(std::nothrow) JsColorFilter(); + if (!jsColorFilter) { + ROSEN_LOGE("Failed to create JsColorFilter"); + return nullptr; + } + status = napi_wrap(env, jsThis, jsColorFilter, JsColorFilter::Destructor, nullptr, nullptr); if (status != napi_ok) { delete jsColorFilter; diff --git a/interfaces/kits/napi/graphic/drawing/font_napi/js_typeface.cpp b/interfaces/kits/napi/graphic/drawing/font_napi/js_typeface.cpp index 1335ceb798..2c3b2ea951 100644 --- a/interfaces/kits/napi/graphic/drawing/font_napi/js_typeface.cpp +++ b/interfaces/kits/napi/graphic/drawing/font_napi/js_typeface.cpp @@ -64,6 +64,10 @@ napi_value JsTypeface::Constructor(napi_env env, napi_callback_info info) } JsTypeface *jsTypeface = new(std::nothrow) JsTypeface(JsTypeface::LoadZhCnTypeface()); + if (!jsTypeface) { + ROSEN_LOGE("Failed to create JsTypeface"); + return nullptr; + } status = napi_wrap(env, jsThis, jsTypeface, JsTypeface::Destructor, nullptr, nullptr); if (status != napi_ok) { diff --git a/interfaces/kits/napi/graphic/drawing/path_napi/js_path.cpp b/interfaces/kits/napi/graphic/drawing/path_napi/js_path.cpp index 26d8721562..35a0e7908c 100644 --- a/interfaces/kits/napi/graphic/drawing/path_napi/js_path.cpp +++ b/interfaces/kits/napi/graphic/drawing/path_napi/js_path.cpp @@ -70,6 +70,10 @@ napi_value JsPath::Constructor(napi_env env, napi_callback_info info) Path *path = new Path(); JsPath *jsPath = new(std::nothrow) JsPath(path); + if (!jsPath) { + ROSEN_LOGE("Failed to create JsPath"); + return nullptr; + } status = napi_wrap(env, jsThis, jsPath, JsPath::Destructor, nullptr, nullptr); diff --git a/interfaces/kits/napi/graphic/drawing/pen_napi/js_pen.cpp b/interfaces/kits/napi/graphic/drawing/pen_napi/js_pen.cpp index 477974009b..24c39acb71 100644 --- a/interfaces/kits/napi/graphic/drawing/pen_napi/js_pen.cpp +++ b/interfaces/kits/napi/graphic/drawing/pen_napi/js_pen.cpp @@ -80,6 +80,11 @@ napi_value JsPen::Constructor(napi_env env, napi_callback_info info) } JsPen* jsPen = new(std::nothrow) JsPen(); + if (!jsPen) { + ROSEN_LOGE("JsPen::Constructor Failed to create JsPen"); + return nullptr; + } + status = napi_wrap(env, jsThis, jsPen, JsPen::Destructor, nullptr, nullptr); if (status != napi_ok) { diff --git a/interfaces/kits/napi/graphic/drawing/text_blob_napi/js_text_blob.cpp b/interfaces/kits/napi/graphic/drawing/text_blob_napi/js_text_blob.cpp index 2f4242d691..fee95cef1d 100644 --- a/interfaces/kits/napi/graphic/drawing/text_blob_napi/js_text_blob.cpp +++ b/interfaces/kits/napi/graphic/drawing/text_blob_napi/js_text_blob.cpp @@ -79,6 +79,10 @@ napi_value JsTextBlob::Constructor(napi_env env, napi_callback_info info) } JsTextBlob *jsTextBlob = new(std::nothrow) JsTextBlob(env, drawingTextBlob); + if (!jsTextBlob) { + ROSEN_LOGE("Failed to create JsTextBlob"); + return nullptr; + } status = napi_wrap(env, jsThis, jsTextBlob, JsTextBlob::Destructor, nullptr, nullptr);